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

Antoine Pitrou solipsis at pitrou.net
Wed Nov 30 18:10:10 CET 2011


On Wed, 30 Nov 2011 16:42:16 +0100
Giampaolo Rodolà <g.rodola at gmail.com>
wrote:
> To be fair, readlines() is different than an iterated file object in
> that it provides the sizehint parameter, so it does cover a use case.
> Maybe the doc should just mention that unless sizehint parameter is
> used the recommended way to get file lines is to iterate against the
> file object itself.

For the record, I don't think I have ever used the sizehint parameter.
It probably serves a purpose but the use cases must be quite
specialized.

Regards

Antoine.





More information about the Python-ideas mailing list