By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,050 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,050 IT Pros & Developers. It's quick & easy.

function nested

P: n/a

i have this function.

def f(start):
stack = []
def f1(start):
for fname in os.listdir(startDir):
path = os.path.join(startDir, fname)
if os.path.isfile(path):
stack.append(path)
else:
f1(path)
return stack
this is returning empty list, why?
thanks

May 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Gigs_ wrote:
i have this function.

def f(start):
stack = []
def f1(start):
for fname in os.listdir(startDir):
path = os.path.join(startDir, fname)
if os.path.isfile(path):
stack.append(path)
else:
f1(path)
return stack
this is returning empty list, why?
Because f() doesn't invoke f1().

Peter
May 24 '07 #2

P: n/a
Gigs_ a écrit :
>
i have this function.

def f(start):
stack = []
def f1(start):
for fname in os.listdir(startDir):
path = os.path.join(startDir, fname)
if os.path.isfile(path):
stack.append(path)
else:
f1(path)
return stack
this is returning empty list, why?
Because that's what you are returning. Perhaps did you mean to actually
*call* f1() after defining it ?-)
May 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.