Tim Chase wrote:
I'd have figured they would be associative, making the result end up
the same either way, but apparently not.
They're not associative because function application
is not associative: f(g(x)) is not the same thing as
f(g)(x).
--
Greg
--
https://mail.python.org/mailman/listinfo/
On 2013-10-29 17:42, MRAB wrote:
> If you apply the stacked decorators you get:
>
> myfun = dec1(args1)(dec2(args2)(dec3(args3)(myfun)))
>
> If you apply dec_all you get:
>
> myfun = dec1(args1)(dec2(args2)(dec3(args3)))(myfun)
>
> See the difference? You need the lambda to fix that.
Tim Chase wrote:
> I've got some decorators that work fine as such:
>
> @dec1(args1)
> @dec2(args2)
> @dec3(args3)
> def myfun(...):
> pass
>
> However, I used that sequence quite a bit, so I figured I could do
> something like
>
> dec_all = dec1(args1)(dec2(args2)(dec3(args3)))
On 29/10/2013 16:54, Tim Chase wrote:
I've got some decorators that work fine as such:
@dec1(args1)
@dec2(args2)
@dec3(args3)
def myfun(...):
pass
However, I used that sequence quite a bit, so I figured I could do
something like
dec_all = dec1(args1)(dec2(args2)(dec3(args3)
I've got some decorators that work fine as such:
@dec1(args1)
@dec2(args2)
@dec3(args3)
def myfun(...):
pass
However, I used that sequence quite a bit, so I figured I could do
something like
dec_all = dec1(args1)(dec2(args2)(dec3(args3)))
to consolidate the whole mess down to
@