A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-September/056190.html below:

[Python-Dev] Example for "property" violates "Python is not a one pass compiler"

[Python-Dev] Example for "property" violates "Python is not a one pass compiler" [Python-Dev] Example for "property" violates "Python is not a one pass compiler"Edward C. Jones edcjones at comcast.net
Mon Sep 5 18:04:33 CEST 2005
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.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4