En Wed, 16 Apr 2008 17:53:16 -0300, <[EMAIL PROTECTED]> escribió:
> On Apr 16, 3:27 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
>
>> Any function can be implemented without recursion, although it isn't
>> always easy or fun.
>>
> Really? I'm curious about that, I can't figure out how that would
> work. Could give an example? Say, for example, the typical: walking
> through the file system hierarchy (without using os.walk(), which uses
> recursion anyway!).
Use a queue of pending directories to visit:
start with empty queue
queue.put(starting dir)
while queue is not empty:
dir = queue.get()
list names in dir
for each name:
if is subdirectory: queue.put(name)
else: process file
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list