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()
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"
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()
--
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
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:
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
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