[Python-ideas] Python-ideas Digest, Vol 140, Issue 169
James Lu
jamtlu at gmail.com
Thu Jul 26 09:45:35 EDT 2018
> You mean lambda x: lumberjack(15, x) ?
Yes, that was my mistake.
> However this syntax you allow to write lumberjack(%, 15) which is only
> possible with partial using keyword arguments, like lumberjack (y=15)
> (given that the second argument is called "y") and in that case I know at
> least one library on pip doing the job with Ellipsis :
>
> from funcoperators import elipartial
> elipartial(lumberjack, ..., 15)
> # gives lambda x: lumberjack (x, 15)
>
> elipartial (lumberjack, ..., 15, ..., 12, ...)
> # gives lambda x, y, z: lumberjack(x, 15, y, 12, z)
>
> And the lib even provide a decorator to have that kind of syntax using "[" :
>
> partially(lumberjack)[15]
> would be the same as partial(lumberjack, 15)
>
> So, that functionality does really need new syntax.
Hm, yes. Perhaps elipartial could be aliased and/or made a global built in. Let’s discuss the merits of the statement itself then.
More information about the Python-ideas
mailing list