[Python-ideas] for line in input with open(path) as input...

Chris Angelico rosuav at gmail.com
Sat Feb 2 14:52:50 CET 2013


On Sun, Feb 3, 2013 at 12:50 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> On 02.02.13 15:01, Chris Angelico wrote:
>>
>> I think the utility function iterwith() is a good - and probably the
>> best - method; it demands nothing special from the language, and works
>> quite happily.
>
>
> When should iterwith() call __exit__()?

According to the OP's posted code, as soon as the iterable runs out.
Not sure what happens if you don't exhaust it but I'm sure generator
functions have already solved that, too.

ChrisA



More information about the Python-ideas mailing list