On Thu, Jul 28, 2011 at 2:44 PM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > path = '/home/gyoung/hacks/pathhack/foo.py' > parts = [part for path, part in iter(lambda: os.path.split(path), ('/', ''))] > parts.reverse() > print parts > > But that's horrendously ugly. Just write a generator with a while > loop or something.
Also, note that if the path does not start with '/', the result will be an infinite loop. -- http://mail.python.org/mailman/listinfo/python-list