Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15586

Re: property decorator and inheritance

References <32311626.67.1320984185425.JavaMail.geo-discussion-forums@yqjc16> <a18d022e-8f1c-46d6-9c5b-b0e6e74a4d3e@l23g2000pro.googlegroups.com> <33183370.2460.1320988631657.JavaMail.geo-discussion-forums@yqcm23>
Date 2011-11-10 21:58 -0800
Subject Re: property decorator and inheritance
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.2639.1320991104.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Nov 10, 2011 at 9:17 PM, Laurent <laurent.payot@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

property decorator and inheritance Laurent <laurent.payot@gmail.com> - 2011-11-10 20:03 -0800
  Re: property decorator and inheritance alex23 <wuwei23@gmail.com> - 2011-11-10 20:43 -0800
    Re: property decorator and inheritance Laurent <laurent.payot@gmail.com> - 2011-11-10 21:17 -0800
      Re: property decorator and inheritance "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-11-11 05:54 +0000
      Re: property decorator and inheritance Chris Rebert <clp2@rebertia.com> - 2011-11-10 21:58 -0800
        Re: property decorator and inheritance Laurent <laurent.payot@gmail.com> - 2011-11-11 01:41 -0800
        Re: property decorator and inheritance Laurent <laurent.payot@gmail.com> - 2011-11-11 01:41 -0800

csiph-web