Re: Closing generators

2011-04-23 Thread Thomas Rachel
Am 23.04.2011 04:15, schrieb Terry Reedy: .close() methods that release operating system resources are needed *because* there is no guarantee of immediate garbage collection. They were not needed when CPython was the only Python. The with statement was added partly to make it easier to make sure

Re: Closing generators

2011-04-22 Thread Terry Reedy
On 4/22/2011 4:01 AM, Thomas Rachel wrote: Am 22.04.2011 09:01, schrieb Wolfgang Rohdewald: On Freitag 22 April 2011, Terry Reedy wrote: 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 n

Re: Closing generators

2011-04-22 Thread Thomas Rachel
Am 22.04.2011 09:01, schrieb Wolfgang Rohdewald: On Freitag 22 April 2011, Terry Reedy wrote: 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 destro

Re: Closing generators

2011-04-22 Thread Wolfgang Rohdewald
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

Re: Closing generators

2011-04-21 Thread Terry Reedy
On 4/21/2011 9:14 PM, Thomas Rachel wrote: Hi folks, it is possible to close a generator. That is (among others) for the following case: I run a for loop over the iterator, but then I break it. Now I can leave the generator to the GC (which is AFAI have been told a thing which I should not do),

Closing generators

2011-04-21 Thread Thomas Rachel
Hi folks, it is possible to close a generator. That is (among others) for the following case: I run a for loop over the iterator, but then I break it. Now I can leave the generator to the GC (which is AFAI have been told a thing which I should not do), or I can clean up myself. Example: f