How to make a method into a property without using the @property decorator
Phlip
phlip2005 at gmail.com
Sat Oct 23 10:56:03 EDT 2010
Pythonistas:
Here's the property decorator:
@property
def foo(self): return 'bar'
If I generate foo dynamically, how to I make it a property?
setattr(self, 'foo', property(lambda: 'bar'))
Variations of that are apparently not working.
(I'm heading for a proxy pattern, where if you never call the
generated prop, you never hit the database to load it into memory.)
--
Phlip
http://zeekland.zeroplayer.com/
More information about the Python-list
mailing list