Re: problem with recursion

2005-03-03 Thread Steve Holden
vegetax wrote: How can i use a counter inside the recursive function? This code gives me the error 'local variable 'c' referenced before assignment' I really don't think it does. I'd believe "local variable 'COUNTER' referenced before assignment". Rule one: always copy and paste the traceback ...

Re: problem with recursion

2005-03-03 Thread vegetax
How can i use a counter inside the recursive function? This code gives me the error 'local variable 'c' referenced before assignment' #!/usr/bin/python from os import listdir from os.path import isdir,join,basename import HTMLgen dirpath = '/devel/python/html/test' COUNTER = 0 def rec(

Re: problem with recursion

2005-03-03 Thread vegetax
Alexander Zatvornitskiy wrote: > ?? vegetax! > > 03 ? 2005 ? 13:54, vegetax ? ? ?? ? All ?: > > v> I need this in order to print a directory tree with htmlgen library > v> which uses nested lists to represent trees. > As you see from output of your code, you simply add item

Re: problem with recursion

2005-03-03 Thread Kent Johnson
vegetax wrote: I am trying to make convert a directory "tree" in a list of list, but cant find the algoritm =( ,for example a directory tree like : #!/usr/bin/python from os import listdir from os.path import isdir,join,basename dirpath = '/tmp/test/' res = [] def rec(f): print f for ele i

Re: problem with recursion

2005-03-03 Thread [EMAIL PROTECTED]
take a look at os.walk, it is documented in the library documentation -- http://mail.python.org/mailman/listinfo/python-list