M
Martin Miller
I'm trying to create some read-only instance specific properties, but
the following attempt didn't work:
Which results in the following ouput instead of '42':
foobar.x: <property object at 0x00AE57B0>
I also tried this:
Can anyone tell me what's wrong with this approach (and perhaps the
correct way to do it, if there is one)?
TIA,
Martin
the following attempt didn't work:
class Foobar(object):
pass
foobar = Foobar()
foobar.x = property(fget=lambda: 42)
print "foobar.x:", foobar.x
Which results in the following ouput instead of '42':
foobar.x: <property object at 0x00AE57B0>
I also tried this:
but get the same behavior.foobar.__dict__['x'] = property(fget=lambda: 42)
Can anyone tell me what's wrong with this approach (and perhaps the
correct way to do it, if there is one)?
TIA,
Martin