Re: How to make a method into a property without using the @property decorator

2010-10-23 Thread Phlip
On Oct 23, 8:01 am, Peter Otten <__pete...@web.de> wrote: > You may be better off with __getattr__(). Ayup, thanks. (Maybe I should have googled for "python equivalent of ruby method_missing", hmm?;) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make a method into a property without using the @property decorator

2010-10-23 Thread Peter Otten
Phlip wrote: > 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. You have to

How to make a method into a property without using the @property decorator

2010-10-23 Thread Phlip
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 ne