Newby help

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


Sussed it (I knew this would happen. Stare at it for hours then as soon as
you post the question, the answer hits you!)

The initial directory doesn't exist. The first call to 'walk' should have
been: walk("D:\\....").

Top prize for a crap error message, though!

If it had mentioned 'file' or 'directory', I might have found it sooner.

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


Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> wrote in message
news:8epob5$jnk$1 at supernews.com...
> 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