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: B.testattr = property(...) Second, the property() call in you example only defines a getter function (the first argument) and not a setter function (the second argument) it defaults to a read-only property. That is why b.testattr='test' would still fail. Raymond -- http://mail.python.org/mailman/listinfo/python-list