Generators and nested functions
Edward C. Jones
edcjones at erols.com
Fri Jan 25 12:55:40 EST 2002
The following code would be a simple way for doing a useful thing except
that it doesn't work. Why not? Any easy fixes?
from __future__ import generators
import os
def walk_dirs(startdir):
def visit(arg, dirname, names):
yield dirname
os.path.walk(startdir, visit, None)
if __name__ == '__main__':
for dir in walk_dirs('/some/small/directory'):
print dir
More information about the Python-list
mailing list