newbie : prune os.walk
Scott David Daniels
Scott.Daniels at Acm.Org
Thu Mar 10 14:24:46 EST 2005
Rory Campbell-Lange wrote:
> Hi. How can I list root and only one level down? I've tried setting dirs
> = [] if root != start root, but it doesn't work. I clearly don't
> understand how the function works. I'd be grateful for some pointers.
base = '/tmp/test'
for root, dirs, files in os.walk(base):
if root != base:
dirs[:] = []
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list