[Python-Dev] Coding guidelines for os.walk filter (original) (raw)
Michael Urman murman at gmail.com
Wed Aug 31 04:21:52 CEST 2011
- Previous message: [Python-Dev] Coding guidelines for os.walk filter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
for t in os.walk(somedir): t[1][:]=set(t[1])-{'.svn','tmp'} ... do something
This is a very clever hack but... it relies on internal implementation of os.walk....
This doesn't appear to be an internal implementation detail; this is documented behavior. http://docs.python.org/dev/library/os.html#os.walk shows a similar example:
for root, dirs, files in os.walk('python/Lib/email'):
# ...
dirs.remove('CVS') # don't visit CVS directories
-- Michael Urman
- Previous message: [Python-Dev] Coding guidelines for os.walk filter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]