waling a directory with very many files

Mike Kazantsev mk.fraggod at gmail.com
Mon Jun 15 19:31:53 EDT 2009


On Mon, 15 Jun 2009 15:35:04 -0400
Terry Reedy <tjreedy at udel.edu> wrote:

> Christian Heimes wrote:
> > Terry Reedy wrote:
> >> You did not specify version.  In Python3, os.walk has become a generater
> >> function.  So, to answer your question, use 3.1.
> > 
> > I'm sorry to inform you that Python 3.x still returns a list, not a
> > generator.
> 
>  >>> type(os.walk('.'))
> <class 'generator'>
> 
> However, it is a generator of directory tuples that include a filename 
> list produced by listdir, rather than a generator of filenames 
> themselves, as I was thinking. I wish listdir had been changed in 3.0 
> along with map, filter, and range, but I made no effort and hence cannot 
> complain.

Why? We have itertools.imap, itertools.ifilter and xrange already.

-- 
Mike Kazantsev // fraggod.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 205 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090616/4109b2dd/attachment.sig>


More information about the Python-list mailing list