[Tutor] properties not working in 2.2

karthik Guru karthikg@aztec.soft.net
Tue, 18 Dec 2001 10:39:48 +0530

hi all,


there is an example to use properties which is not workign for me under
Python 2.2a1

class C(object):
    def __init__(self):
        print "hello world"
        self.__x = 0
    def getx(self):
        print "get called"
        return self.__x
    def setx(self, x):
        print "set called"
        if x < 0: x = 0
        self.__x = x
    x = property(getx,setx,None,"this is property")

this is the trace....

  File "test.py", line 13, in C
    x = property(getx,setx,None,"this is property")
NameError: name 'property' is not defined

can someone tell me as what's wrong here? ..python2.2 a1 does not have this