[PyQt] question about dip observe handler

Phil Thompson phil at riverbankcomputing.com
Mon Jul 19 14:33:39 BST 2010


On Sun, 18 Jul 2010 18:11:15 -0400, Darren Dale <dsdale24 at gmail.com>
wrote:
> I am reading the dip documentation at
>
http://www.riverbankcomputing.co.uk/static/Docs/dip/complete_example.html
> , and have a question about the following:
> 
> "dip will invoke an observe() handler when the value of an attribute
> is set, even if the new value is the same as the old one. We therefore
> use the _propagate_changes attribute to prevent possible recursion
> problems"
> 
> Why is it necessary to invoke the observe handler when the value of an
> attribute does not change? There are quite a few infinite-recursion
> workarounds in the example. If the possibility of infinite recursion
> is so high, perhaps by default the handler should not be invoked if
> the attribute value does not change, unless observe() was called with
> a kwarg to invoke the handler regardless?

Good question.

The short answer is that it was easiest for me, but (obviously) what
matters is what's easier for developers using it.

The issue is to define what is meant by "changed", particularly when the
attribute is a class instance? Rebinding the attribute is obviously a
change, but what about a change to an attribute of the instance?

Phil


More information about the PyQt mailing list