[Tutor] turn a path into nested list

ingo ingoogni at gmail.com
Thu Jan 13 13:33:39 CET 2011


Dear all,

a probably simple problem I can't get my head around at the moment
(old age?), some input would be appreciated.

I have a path

>>> path = 'Audio/site-packages/pygame/examples/macosx/aliens_app_example/English.lproj'

I'd like to turn taht into a list with a certain structure and order:

[['Audio', 'Audio'],
['site-packages', ''Audio/site-packages'],
['pygame', 'Audio/site-packages/pygame'],
['examples', 'Audio/site-packages/pygame/examples'],
['macosx', ''Audio/site-packages/pygame/examples/macosx'],
.
.
]

How to approach this?

TIA,

ingo


More information about the Tutor mailing list