On Thu, Oct 20, 2016 at 7:14 AM, Neil Girdhar <[email protected]> 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
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/