[Python-ideas] Addition to operator module: starcaller

Franklin? Lee leewangzhong+python at gmail.com
Sat Aug 6 03:55:32 EDT 2016


On Jul 29, 2016 11:00 PM, "Michael Selik" <michael.selik at gmail.com> wrote:
> If it goes in the operator module, then the name ``operator.starcall``
seems better than ``starcaller``. I'd say ``operator.unpack`` would be
better, except for the confusion between unpacking assignment and unpacking
as arguments. I suppose ``operator.apply`` would be OK, too. Is there a
better vocabulary word for unpack-as-args?

Not sure if "splat" is better.

`operator.starcall(f, *args, **kwargs)` isn't obvious, unless you know
`itertools.starmap` and `map`.

`operator.unpack(...)` can be obvious, and the obvious meanings for many
are probably wrong. That's bad. "unpack[ed]call" is ugly, long, and three
syllables.

On Jul 30, 2016 1:57 AM, "Brendan Barnwell" <brenbarn at brenbarn.net> wrote:
> Why not just operator.call?  I suppose actually operator.caller would be
more consistent with the existing attrgetter and methodcaller?

The desired meaning of `somename(x, y)` is `x(*y)`.

`call(x,y)` looks like it should be equivalent to `x.__call__(y)`, which
means `x(y)`.

`attrgetter(x)(y)` means `getattr(y,x)` (in the simple case), and
`methodcaller(m,x)(y)` means `getattr(y,m)(x)`, so `caller(x)(y)` might
mean `y(x)`. `operator.thinger` is for reverse currying: `thingdoer(x)`
returns a new callable, and `thingdoer(x)(y)` means `dothing(y,x)`
(conceptually).

(I'm not sure if the original proposal of a wrapper would be called
`starrer(f)(args)` or `unstarrer(f)(args)`,and that bugs me.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160806/ba053d09/attachment.html>


More information about the Python-ideas mailing list