os.path.walk() question.

Moshe Zadka moshez at math.huji.ac.il
Wed Apr 26 04:21:07 EDT 2000


On 25 Apr 2000, Andrew McDowell wrote:

> 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?

Here's a quick-n-dirty hack: throw an exception, containing the name
of the file you found.

--
Moshe Zadka <mzadka at geocities.com>. 
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list