I'm trying to create some read-only instance specific properties, but
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:
> foobar.__dict__['x'] = property(fget=lambda: 42)
but get the same behavior.

Can anyone tell me what's wrong with this approach (and perhaps the
correct way to do it, if there is one)?

TIA,
Martin

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to