Dave Angel wrote:
> The decorator function will execute while *compiling* the class A, and
> the one in class B is unreferenced.
No, the decorator function is called when *executing* the class body of A.
Compilation could have happened weeks earlier.
It really does make it a lot easier to und
Jason Swails於 2013年1月31日星期四UTC+8上午8時34分03秒寫道:
> Hello,
>
>
> I was having some trouble understanding decorators and inheritance and all
> that. This is what I was trying to do:
>
>
>
> # untested
> class A(object):
> def _protector_decorator(fcn):
>
> def newfcn(self, *args, **kwar
On Thu, Jan 31, 2013 at 6:16 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
>
> Normally, subclasses should extend functionality, not take it away. A
> fundamental principle of OO design is that anywhere you could sensibly
> allow an instance, should also be able to use a subcl
Jason Swails wrote:
> On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano <
> steve+comp.lang.pyt...@pearwood.info> wrote:
>> Well, that surely isn't going to work, because it always decorates the
>> same function, the global "fcn".
>
> I don't think this is right.
It certainly isn't. Sorry fo
Steven D'Aprano wrote:
>> def _protector_decorator(fcn):
>> def newfcn(self, *args, **kwargs):
>> return fcn(self, *args, **kwargs)
>> return newfcn
>
> Well, that surely isn't going to work, because it always decorates the
> same function, the global "fcn".
Good grief, I can't b
On Thu, Jan 31, 2013 at 11:00 AM, Jason Swails wrote:
>
>
> On Thu, Jan 31, 2013 at 10:28 AM, Chris Angelico wrote:
>
>>
>> >> Well, that surely isn't going to work, because it always decorates the
>> >> same function, the global "fcn".
>> >
>> >
>> > I don't think this is right. fcn is a passed
On Thu, Jan 31, 2013 at 10:28 AM, Chris Angelico wrote:
>
> >> Well, that surely isn't going to work, because it always decorates the
> >> same function, the global "fcn".
> >
> >
> > I don't think this is right. fcn is a passed function (at least if it
> acts
> > as a decorator) that is declare
On Fri, Feb 1, 2013 at 12:25 AM, Jason Swails wrote:
> On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano
> wrote:
>>
>> On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote:
>>
>> > Hello,
>> >
>> > I was having some trouble understanding decorators and inheritance and
>> > all that. This is w
On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
> On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote:
>
> > Hello,
> >
> > I was having some trouble understanding decorators and inheritance and
> > all that. This is what I was trying to do:
> >
On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote:
> Hello,
>
> I was having some trouble understanding decorators and inheritance and
> all that. This is what I was trying to do:
>
> # untested
> class A(object):
>def _protector_decorator(fcn):
> def newfcn(self, *args, **kwarg
On 01/30/2013 07:34 PM, Jason Swails wrote:
Hello,
I was having some trouble understanding decorators and inheritance and all
that. This is what I was trying to do:
# untested
class A(object):
def _protector_decorator(fcn):
def newfcn(self, *args, **kwargs):
return fcn(sel
Hello,
I was having some trouble understanding decorators and inheritance and all
that. This is what I was trying to do:
# untested
class A(object):
def _protector_decorator(fcn):
def newfcn(self, *args, **kwargs):
return fcn(self, *args, **kwargs)
return newfcn
@_pro
12 matches
Mail list logo