Newby help

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Wed May 3 13:39:50 EDT 2000


I'm learning Python - just for the hell of it really - but I don't
understand what's going on here:

import os

def walk(dir, dent = 1):
    print ">" * dent, dir
    for item in os.listdir(dir):
        if os.path.isdir(dir + item):
            walk(dir + item, dent + 3)
        else:
            print " " * dent, item

print "\n\n\n\n"

walk("C:\\program files\\python\\")


If I run the above code, it throws an "OSError: [Errno 3] No such process"
error at the 'for' statement.

This is on NT 4 and the os.listdir(whatever) works fine interactively.

I know there's a walk function already but I'm trying to get the hang of
this.

Thanks for any help.

--
Dale Strickland-Clark
Out-Think Ltd, UK
Business Technology Consultants






More information about the Python-list mailing list