Hi,

[python 2.7] I have a (linux) pathname that I'd like to split
completely into a list of components, e.g.:
    '/home/gyoung/hacks/pathhack/foo.py'  -->   ['home', 'gyoung',
'hacks', 'pathhack', 'foo.py']

Not sure what your exact requirements are, but the following seems to work:

pathname = '/home/gyoung/hacks/pathhack/foo.py'
print pathname[1:].split("/")

Note that this would only work for absolute linux paths (i.e. starting with "/").

Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to