Newby help
Dale Strickland-Clark
dale at out-think.NOSPAMco.uk
Fri May 5 11:18:33 EDT 2000
Thanks. I got it working.
--
Dale Strickland-Clark
Out-Think Ltd, UK
Business Technology Consultants
Robert Cragie <rcc at nospamthanks_jennic.com> wrote in message
news:newscache$jdb3uf$ltb$1 at jenpc07.jennic.co.uk...
> The following works properly:
>
> 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\\")
>
> Robert Cragie
>
> 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