[Python-ideas] Is there a reason why file.readlines() doesn't/can't return an iterator?

Masklinn masklinn at masklinn.net
Wed Nov 30 14:57:16 CET 2011


On 2011-11-30, at 14:54 , Amaury Forgeot d'Arc wrote:
> 2011/11/30 Eli Bendersky <eliben at gmail.com>
>> linesgen = (line for line in file)
>> 
> 
> Shorter::
>    iter(file)
Even shorter::
    file

(iter(file) just returns the file object in Python2, and the BufferedReader in Python3, so it's a useless indirection)


More information about the Python-ideas mailing list