How to walk up parent directories?

Matthew Wilson matt at
Mon May 4 03:04:31 CEST 2009

Is there already a tool in the standard library to let me walk up from a
subdirectory to the top of my file system?

In other words, I'm looking for something like:

    >>> for x in walkup('/home/matt/projects'):
    ...     print(x)

I know I could build something like this with various os.path
components, but I'm hoping I don't have to.



More information about the Python-list mailing list