problem with recursion
vegetax
vegeta.z at gmail.com
Thu Mar 3 17:18:26 EST 2005
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(f):
res = []
COUNTER += 1
for ele in listdir(f):
res.append(ele)
ele = join(f,ele)
if isdir(ele):
res.append(rec(ele))
return res
print HTMLgen.List(rec(dirpath))
More information about the Python-list
mailing list