How to walk up parent directories?
dns4 at cornell.edu
Mon May 4 09:58:40 EDT 2009
Matthew Wilson wrote:
> 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.
You should take a look at the os.path module. Seems like you might find
something in that toolbox for this.
More information about the Python-list