On 09/11/2016 08:28 AM, Peter Otten wrote:
Nagy László Zsolt wrote:
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.
In other words, you would use simple getter and setter methods instead
of properties. It is the simplest solution. (And I believe, it is
non-pythonic, but that is just an opinion.)
I would like to hear other opinions.
Disregarding potential implementation obstacles I think it would be clean
and clear if you could access a property foo in a base class with
super().foo
and set it with
super().foo = value
It looks like the get part already works:
class A:
... @property
... def foo(self): return "foo"
...
class B(A):
... @property
... def foo(self): return super().foo.upper()
...
A().foo
'foo'
B().foo
'FOO'
Yes, the get part works. The set part is a pain, and a bit ugly:
super(B, B).foo.__set__(self, value)
There is an issue for this on the tracker: http://bugs.python.org/issue14965
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list