[Python-ideas] Automatic context managers
Joao S. O. Bueno
jsbueno at python.org.br
Wed Apr 24 13:50:34 CEST 2013
On 24 April 2013 05:59, anatoly techtonik <techtonik at gmail.com> wrote:
> PySide Qt binding have an interesting property - when you create widgets,
> you need to assign them to variables. When such variable is lost, object is
> immediately destroyed.
I truly hope it is not quite as you describe - otherwisew pySie would
be completly unusable.
What if one adds created objects to a list, instead of assigning them
to a variable?
Otherwiser, reference counting is usually enough in cPython to trigger
object destruction -
and if it was not working as this before, it was broken. (It is so in
tkinter, for example:
>>> import tkinter
>>> t = tkinter.Tk()
>>> del t
>>>
And the window it created is kept open - it indeed should be destroyed
just as you put it. It can't be changed
in tkinter now, or it would certainly break more than half the
programs that use it.
js
-><-
More information about the Python-ideas
mailing list