bug in property?

Simon Brunning simon.brunning at gmail.com
Fri Aug 12 14:19:15 CEST 2005


On 8/12/05, Damir Hakimov <damir at agg.astranet.ru> wrote:
> #!/usr/bin/python2.4
> class test_property:
>     def __init__(self):
>         self._x="Zero"
>         pass
>     def setx(self,x):
>         print "set x"  #this is not work
>         self._x=x
>     def getx(self): return self._x
>     def delx(self): del(self._x)
>     x=property(getx,setx,delx,"XXX")
> t=test_property()
> t.x=1
> print t.x

Properties only work with new style classes, so try:

class test_property(object):

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list