property () for Java Programmers ?

michael michael.bierenfeld at
Wed Jan 12 12:04:49 EST 2005

Hi there,

I am somewhat confused by the following :

class C(object):
    def getx(self): return self.__x
    def setx(self, value): self.__x = "extended" + value
    def delx(self): del self.__x
    x = property(getx, setx, delx, "I'm the 'x' property.")

So far so good :-) But what to do with this now

>>> c = C
>>> c
<class '__main__.C'>
>>> dir (c)
['__class__', '__delattr__', '__dict__', '__doc__',
'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'__weakref__', 'delx', 'getx', 'setx', 'x']
>>> c.x
<property object at 0x401edbbc>

?????? What can I do with this "property object" now.

Confused greetings


More information about the Python-list mailing list