On Monday 27 April 2015 12:37, Makoto Kuwata wrote:
def multiply(n):
def deco(func):
def newfunc(*args, **kwargs):
return n * func(*args, **kwargs)
return newfunc
return deco
I'd like to be able to write that as
def multiply(n)(func)(*args, **kwargs):
return n
On 04/27, Maxime S wrote:
> Le lun. 27 avr. 2015 à 04:39, Makoto Kuwata a écrit :
> >
> > If function decorator notation could take arguments,
> > decorator definition would be more simple:
> >
> > def multiply(func, n):
> > def newfunc(*args, **kwargs):
> > return n * func(*args, **kw
Le lun. 27 avr. 2015 à 04:39, Makoto Kuwata a écrit :
>
> If function decorator notation could take arguments,
> decorator definition would be more simple:
>
> def multiply(func, n):
> def newfunc(*args, **kwargs):
> return n * func(*args, **kwargs)
> return newfunc
>
> @multiply
On Monday 27 April 2015 12:37, Makoto Kuwata wrote:
> I want to ask Python experts about function decorator which has arguments.
>
> I feel that function decorator having arguments is complicated,
> because three 'def' are nested:
>
> def multiply(n):
> def
(Redirecting to the list - hope you don't mind)
On Mon, Apr 27, 2015 at 2:36 PM, Makoto Kuwata wrote:
>
>
> On Mon, Apr 27, 2015 at 12:20 PM, Chris Angelico wrote:
>>
>>
>> I agree it would be nice to have extra parameters directly handled,
>> but before you go further with the proposal, I sugge
On Mon, Apr 27, 2015 at 2:45 PM, Ethan Furman wrote:
>> What's the advantage of that over a simple closure? You have the same
>> number of nesting levels, plus a lot more boiler-plate repetition -
>> instead of just referencing names from the outer scope, you have to
>> explicitly capture them all
On 04/27, Chris Angelico wrote:
> On Mon, Apr 27, 2015 at 2:24 PM, Ethan Furman wrote:
> > On 04/27, Makoto Kuwata wrote:
> >>
> >> I feel that function decorator having arguments is complicated,
> >> because three 'def' are nested:
>
On Mon, Apr 27, 2015 at 2:24 PM, Ethan Furman wrote:
> On 04/27, Makoto Kuwata wrote:
>>
>> I feel that function decorator having arguments is complicated,
>> because three 'def' are nested:
>>
>> def multiply(n):
>> def deco(func):
>>
On 04/27, Makoto Kuwata wrote:
>
> I feel that function decorator having arguments is complicated,
> because three 'def' are nested:
>
> def multiply(n):
> def deco(func):
> def newfunc(*args, **kwargs):
> return n * func(*args, **kwargs)
&
On Mon, Apr 27, 2015 at 12:37 PM, Makoto Kuwata wrote:
> If function decorator notation could take arguments,
> decorator definition would be more simple:
>
> def multiply(func, n):
> def newfunc(*args, **kwargs):
> return n * func(*args, **kwargs)
> return newfunc
>
> @multiply
I want to ask Python experts about function decorator which has arguments.
I feel that function decorator having arguments is complicated,
because three 'def' are nested:
def multiply(n):
def deco(func):
def newfunc(*args, **kwargs):
return n * func(*args
11 matches
Mail list logo