function nested

Peter Otten __peter__ at web.de
Thu May 24 05:42:31 EDT 2007


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



More information about the Python-list mailing list