Breaking out of walk()

Robert Roy rjroy at takingcontrol.com
Sun Jan 16 11:36:10 EST 2000


On Sat, 15 Jan 2000 17:01:08 -0800, "Roberts, Robert J"
<ROBERT_J_ROBERTS at rl.gov> wrote:

>Is there a way to gracefully break out of os.path.walk()?
>
names[:]=[]

Make sure you modify the list in-place. Don't do names=[] since that
creates a reference to a different object. You can also choose not to
recurse through certain directories.

if 'cvs' in names: names.remove('cvs')

will skip over directories named 'cvs'





More information about the Python-list mailing list