Override property setter of base class in Python 3 - USE CASE

Chris Angelico rosuav at gmail.com
Sun Sep 11 08:05:46 EDT 2016


On Sun, Sep 11, 2016 at 9:31 PM, Nagy László Zsolt <gandalf at shopzeus.com> wrote:
> The "value of a form field" must have a unified interface. So when I do
> " textfield.value = some_value " then I expect that the changed value
> will be represented on the UI *if it has an UI representation*. The
> widget needs to be able to intercept property value changes.
>
> Does this go beyond the normal use of properties? You decide. I'm open
> to suggestions. What other pattern can I use for this problem?

Yes, I believe it does. (Others may disagree. This is a design
question and very much a matter of style, not hard fact.) I would have
an explicit action "set_content" which will set the value of an input
field, the inner text of a textarea, the checked state of a check box,
etc.

ChrisA



More information about the Python-list mailing list