On 13/01/2011 14:33, ingo wrote:
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
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
First split your path into segments, then iterate over those segments
and build your new list (item one being the current segment, and part
two a joined string of previous segments).
--
Kind Regards,
Christian Witts
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor