[Python-checkins] CVS: python/nondist/peps pep-0213.txt,1.4,1.5
Guido van Rossum
gvanrossum@users.sourceforge.net
Wed, 01 Aug 2001 11:43:37 -0700
Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv15699
Modified Files:
pep-0213.txt
Log Message:
Add a note explaining how PEP 252 enables a different solution.
Index: pep-0213.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0213.txt,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pep-0213.txt 2000/08/23 05:47:12 1.4
--- pep-0213.txt 2001/08/01 18:43:34 1.5
***************
*** 26,30 ****
Justification
! Scenario 1:
You have a deployed class that works on an attribute named
--- 26,30 ----
Justification
! cenario 1:
You have a deployed class that works on an attribute named
***************
*** 209,212 ****
--- 209,229 ----
Once again, the solution is to use a special (typically private)
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.