469,160 Members | 1,854 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,160 developers. It's quick & easy.

function nested


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
2 1113
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
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.

Similar topics

1 post views Thread by Bart Nessux | last post: by
3 posts views Thread by Richard A. DeVenezia | last post: by
26 posts views Thread by Adam Warner | last post: by
7 posts views Thread by Jim Crate | last post: by
78 posts views Thread by Josiah Manson | last post: by
3 posts views Thread by jdurancomas | last post: by
4 posts views Thread by Wolfgang Draxinger | last post: by
2 posts views Thread by Johannes Bauer | last post: by
4 posts views Thread by Immortal_Nephi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.