1

I can do

class Foo(object):
    x = property(lambda _: 123)        
f = Foo()
f.x

to get 123

However, if I try

p = property(lambda : 123)
p

I get

<property object at 0x108f2f3b8>

Now I understand that an member of a class instance is not the same thing as a regular variable but I'm not sure what exactly makes this behavior different.

Does the fact that you instantiate a class somehow do extra binding on property objects? Is it a special case or is it a behavior I can take advantage in other situations and extend? Related - are property objects useful outside of a class declaration? Or is it just for this specific case?

George Mauer
  • 117,483
  • 131
  • 382
  • 612

0 Answers0