[Python-ideas] os.listdir iteration support

Neil Toronto ntoronto at cs.byu.edu
Fri Nov 23 08:18:37 CET 2007

Adam Atlas wrote:
> On 22 Nov 2007, at 23:59, Aahz wrote:
>> Because the list needs to be created in the first place
> How so?

It doesn't, actually. On Windows, os.listdir uses FindFirstFile and 
FindNextFile, on OS2 it's DosFindFirst and DosFindNext, and on 
everything else it's Posix opendir and readdir. All of these are 
incremental, so a generator is the most natural way to expose the 
underlying API.

That's just a set of facts and a single opinion. Past that I personally 
have no preference.


More information about the Python-ideas mailing list