1

I have the following dict:

In [37]: print(paths)
{'definition': ['dirname', 'basename'],
'condition': ['isdir', 'isfile', 'islink', 'isabs', 'ismount', 'exists', 'lexists'],
'get': ['getatime', 'getctime', 'getmtime', 'getsize'],
'split': ['split', 'splitdrive', 'splitext', 'join', 'normcase'],
'expand': ['expanduser', 'expandvars'],
'same': ['samefile', 'sameopenfile', 'samestat'],
'path': ['abspath', 'commonpath', 'defpath', 'genericpath', 'normpath', 'pathsep', 'realpath', 'relpath']}

The result I want is a path_list:

In [38]: path_list = []
    ...: for v in paths.values():
    ...:     path_list.append(v)
In [42]: print(path_list)
['dirname', 'basename', 'isdir', 'isfile', 'islink', 'isabs', 'ismount', 'exists', 'lexists', 'getatime', 'getctime', 'getmtime', 'getsize', 'split', 'splitdrive', 'splitext', 'join', 'normcase', 'expanduser', 'expandvars', 'samefile', 'sameopenfile', 'samestat', 'abspath', 'commonpath', 'defpath', 'genericpath', 'normpath', 'pathsep', 'realpath', 'relpath']

I attempt to solve the problem with inline codes.

In [43]: [ v for v in paths.values()]
Out[43]:
[['dirname', 'basename'],
 ['isdir', 'isfile', 'islink', 'isabs', 'ismount', 'exists', 'lexists'],
 ['getatime', 'getctime', 'getmtime', 'getsize'],
 ['split', 'splitdrive', 'splitext', 'join', 'normcase'],
 ['expanduser', 'expandvars'],
 ['samefile', 'sameopenfile', 'samestat'],
 ['abspath',
  'commonpath',
  'defpath',
  'genericpath',
  'normpath',
  'pathsep',
  'realpath',
  'relpath']]

It doesn't produce my results.

How to accomplish it?

PM 2Ring
  • 54,345
  • 6
  • 82
  • 182

0 Answers0