On Sat, Nov 29, 2014 at 4:55 AM, Marko Rauhamaa <ma...@pacujo.net> wrote:
> I think the OP can learn from the comparison. One question, many
> lessons:
>
>  * Here's how you write a generator.
>
>  * Here's how you write a context manager class. You run into those
>    quite often as well.
>
>  * See how much more suitable a generator is in this case.
>
> No need to shoot down those who only try to be helpful.

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).

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to