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 ...
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(
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
Привет 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 items to the only list. Try
this:
v> def rec(f):
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
take a look at os.walk, it is documented in the library documentation
--
http://mail.python.org/mailman/listinfo/python-list
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 :
+root
+doc
ele1
ele2
+doc3
ele3
+doc2
ele4
ele5
should convert into:
root[
doc,
[ele1,ele2,doc3,[ele3]],
doc2,
[ele4],