On 1/24/07, Giovanni Bajo <[EMAIL PROTECTED]> wrote:
> On 24/01/2007 21.19, Guido van Rossum wrote:

> > (For example, I looked briefly into making os.listdir() an iterator,
> > but decided against it because you'd have a file descriptor open while
> > iterating, and the list is never truly long.)

> What is so wrong about having a file descriptor open while iterating? I can't
> help but thinking of "for L in open(...)" which works out pretty well.

Directories are a special case.  Iteration over a file probably won't
cause you to need additional file descriptions.  Iteration over a
directory often will, and the function is likely to be called
recursively, like the various *.walk functions.  Using up one file
descriptor to keep memory use low is reasonable.  Using up ten may not
be, unless directories are truly huge.

-jJ
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to