function nested

Amit Khemka khemkaamit at gmail.com
Thu May 24 06:00:43 EDT 2007


On 5/24/07, Gigs_ <gigs at hi.t-com.hr> wrote:
> def f(start):
>      stack = []
>      def f1(start):
>          for fname in os.listdir(start):
>             path = os.path.join(start, fname)
>             if os.path.isfile(path):
>                 stack.append(path)
>             else:
>                 f1(path)
>      f1(start)
>      return stack
>
>
> i feel s stupid right now
> forgot to call f1
>
> any comments how to make this better?

os.walk is just the way for you !

Cheers,

----
Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.



More information about the Python-list mailing list