On Thu, Oct 20, 2016 at 7:14 AM, Neil Girdhar <mistersh...@gmail.com> wrote:
> class AddIterclose:
>
>     def __init__(self, iterable, iterclose):
>         self.iterable = iterable
>         self.iterclose = iterclose
>
>     def __iter__(self):
>         try:
>             for x in self.iterable:
>                 yield x
>         finally:
>             self.iterclose()

Can this be simplified down to a generator?

def AddIterclose(iterable, iterclose):
    try:
        yield from iterable
    finally:
        iterclose()

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to