Here is an example from the "Python Library Reference", Section 2.1
"Built-in Functions":
class C(object):
def getx(self): return self.__x
def setx(self, value): self.__x = value
def delx(self): del self.__x
x = property(getx, setx, delx, "I'm the 'x' property.")
It works. But if I put the property statement first:
class C(object):
x = property(getx, setx, delx, "I'm the 'x' property.")
def getx(self): return self.__x
def setx(self, value): self.__x = value
def delx(self): del self.__x
I get the error:
NameError: name 'getx' is not defined
Does this violate the principle "Python is not a one pass compiler"?
Normally I can use any method of a class anywhere in the definition of
the class.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com