Closing generators
Wolfgang Rohdewald
wolfgang at rohdewald.de
Fri Apr 22 03:01:45 EDT 2011
On Freitag 22 April 2011, Terry Reedy wrote:
> > for i in g:
> > if i is not None:
> > g.close()
> > return i
>
> When returning from the function, g, if local, should
> disappear.
yes - it disappears in the sense that it no longer
accessible, but
AFAIK python makes no guarantees as for when an object
is destroyed - CPython counts references and destroys
when no reference is left, but that is implementation
specific
--
Wolfgang
More information about the Python-list
mailing list