Breaking out of walk()

Fredrik Lundh fredrik at pythonware.com
Sun Jan 16 14:44:31 EST 2000


Gerrit Holl <gerrit.holl at pobox.com> wrote:
> Robert Roy wrote on 948036970:
> > if 'cvs' in names: names.remove('cvs')
> > 
> > will skip over directories named 'cvs'
> 
> It won't:
> >>> l = ['foo', 'cvs', 'bar', 'cvs']
> >>> l.remove('cvs')
> >>> l
> ['foo', 'bar', 'cvs']

it will -- when the walk callback is called, the "names"
argument only contains the files and subdirectories
directly under "dirname"...

(if os.listdir returns duplicates on your computer,
you should fix your operating system)

</F>





More information about the Python-list mailing list