Re: Overwriting property-> can't set attribute

2008-08-26 Thread Bruno Desthuilliers
Gregor Horvath a écrit : Hi, why is this code failing? class B(object): pass B.testattr = property(lambda s:"hallo") b = B() b.testattr = "test" Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) /tmp/python-14202ViU.py in () 14 B.testattr = property(lambda s:"hallo") 15 b = B()

Re: Overwriting property-> can't set attribute

2008-08-26 Thread Bruno Desthuilliers
norseman a écrit : Gregor Horvath wrote: Hi, why is this code failing? class B(object): pass B.testattr = property(lambda s:"hallo") b = B() b.testattr = "test" Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) /tmp/python-14202ViU.py in () 14 B.testattr = property(lambda s:"hallo"

Re: Overwriting property-> can't set attribute

2008-08-22 Thread norseman
Gregor Horvath wrote: Hi, why is this code failing? class B(object): pass B.testattr = property(lambda s:"hallo") b = B() b.testattr = "test" Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) /tmp/python-14202ViU.py in () 14 B.testattr = property(lambda s:"hallo") 15 b = B() --

Re: Overwriting property-> can't set attribute

2008-08-22 Thread Bruno Desthuilliers
Raymond Hettinger a écrit : On Aug 22, 5:38 am, Gregor Horvath <[EMAIL PROTECTED]> wrote: why is this code failing? class B(object): pass B.testattr = property(lambda s:"hallo") b = B() b.testattr = "test" First, property() only works when attached to classes, not instances. So the assi

Re: Overwriting property-> can't set attribute

2008-08-22 Thread Raymond Hettinger
On Aug 22, 5:38 am, Gregor Horvath <[EMAIL PROTECTED]> wrote: > why is this code failing? > > class B(object): >      pass > > B.testattr = property(lambda s:"hallo") > b = B() > b.testattr = "test" First, property() only works when attached to classes, not instances. So the assignment should be:

Re: Overwriting property-> can't set attribute

2008-08-22 Thread Gregor Horvath
Gregor Horvath schrieb: why is this code failing? OK I answer myself :-) Because there is not fset function definied in the property. I have to del the attr before rebinding the attributename to another object. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Overwriting property-> can't set attribute

2008-08-22 Thread Gregor Horvath
Hi, why is this code failing? class B(object): pass B.testattr = property(lambda s:"hallo") b = B() b.testattr = "test" Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) /tmp/python-14202ViU.py in () 14 B.testattr = property(lambda s:"hallo") 15 b = B() ---> 16 b.testattr = "tes