Add a note explaining how PEP 252 enables a different solution.
This commit is contained in:
parent
d90c6d41a7
commit
3ba9f35d1b
19
pep-0213.txt
19
pep-0213.txt
|
@ -25,7 +25,7 @@ Introduction
|
||||||
|
|
||||||
Justification
|
Justification
|
||||||
|
|
||||||
Scenario 1:
|
cenario 1:
|
||||||
|
|
||||||
You have a deployed class that works on an attribute named
|
You have a deployed class that works on an attribute named
|
||||||
"stdout". After a while, you think it would be better to
|
"stdout". After a while, you think it would be better to
|
||||||
|
@ -210,6 +210,23 @@ Caveats
|
||||||
variable such as __XXX.
|
variable such as __XXX.
|
||||||
|
|
||||||
|
|
||||||
|
Note
|
||||||
|
|
||||||
|
The descriptor mechanism described in PEP 252 is powerful enough
|
||||||
|
to support this more directly. A 'getset' constructor may be
|
||||||
|
added to the language making this possible:
|
||||||
|
|
||||||
|
class C:
|
||||||
|
def get_x(self):
|
||||||
|
return self.__x
|
||||||
|
def set_x(self, v):
|
||||||
|
self.__x = v
|
||||||
|
x = getset(get_x, set_x)
|
||||||
|
|
||||||
|
Additional syntactic sugar might be added, or a naming convention
|
||||||
|
could be recognized.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Local Variables:
|
Local Variables:
|
||||||
mode: indented-text
|
mode: indented-text
|
||||||
|
|
Loading…
Reference in New Issue