Iterate over text file, discarding some lines via context manager

Marko Rauhamaa marko at pacujo.net
Fri Nov 28 19:04:49 CET 2014


Chris Angelico <rosuav at gmail.com>:

> Since we're so good at it on this list, I will nit-pick: that's not a
> context manager class, that's an iterator class. A context manager has
> __enter__ and __exit__, an iterator has __iter__ (returning self) and
> __next__ (returning or raising StopIteration).

Excellent. Learnings will never end.


Marko



More information about the Python-list mailing list