os.path.walk() question.

Justin Sheehy dworkin at ccs.neu.edu
Tue Apr 25 19:36:51 EDT 2000


"Andrew McDowell" <drew.mcdowell at msfc.nasa.gov> writes:

> I need to find out if a file exists under a directory hierarchy.
> The hierarchy could be quite large so I don't want to continue recursing
> through the hierarchy if the file is found one or two directories down.   Is
> there a way that you can tell os.path.walk() to stop searching?

You could put the os.path.walk() call inside a try/except, and raise
an appropriate exception when the desired item is found.

-Justin

 




More information about the Python-list mailing list