property decorator and inheritance
Chris Rebert
clp2 at rebertia.com
Fri Nov 11 00:58:21 EST 2011
On Thu, Nov 10, 2011 at 9:17 PM, Laurent <laurent.payot at gmail.com> wrote:
> Yes using a separate class variable would transfer the problem to the class level. But adding 10 class variables if I have 10 properties would be ugly. Maybe I should reformulate the subject of this thread to "is there some python magic to pass parameters to decorator-declared properties ?"
Apparently, yes:
>>> class Foo(object):
... @property
... def bar(self, arg1='baz', arg2='qux'):
... return arg1, arg2
...
>>> Foo.bar.fget(Foo(), 'spam', 'eggs')
('spam', 'eggs')
>>>
Though I do not like this trick at all.
Cheers,
Chris
--
http://rebertia.com
More information about the Python-list
mailing list