[Python-ideas] Automatic context managers

anatoly techtonik techtonik at gmail.com
Thu Apr 25 05:49:50 CEST 2013


On Wed, Apr 24, 2013 at 2:50 PM, Joao S. O. Bueno <jsbueno at python.org.br>wrote:

> 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?
>

As long as the list references the widget, the widget won't be destroyed.
"assign to variable" is not a correct term - I guess "reference keeping" is
better.


> Otherwiser, reference counting is usually enough in cPython to trigger
> object destruction -
>

It is no guaranteed, so you can have a delayed shot in the foot, which is
times worse that immediate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130425/5f4831e1/attachment.html>


More information about the Python-ideas mailing list