[Python-ideas] Addition to operator module: starcaller

Emanuel Barry vgr255 at live.ca
Thu Jul 21 11:48:15 EDT 2016


> From: Nick Coghlan
> Sent: Thursday, July 21, 2016 11:21 AM
> 
> On 22 July 2016 at 00:19, Emanuel Barry <vgr255 at live.ca> wrote:
> > Hello,
> >
> > You’re presumably doing something like ‘star = starcaller(f); star((“foo”,
> > “bar”, “baz”))’ – how is it different from ‘f(*(“foo”, “bar”, “baz”))’ ? I
> > don’t see any difference…
> 
> Similar to functools.partial, it lets you more easily separate the
> process of changing a function's signature from actually calling it.
> 
> Compare:
> 
>     def f(a, b):
>         print(a, b)
> 
>     accepts_only_b = functools.partial(f, "predefined_a")
>     accepts_args_as_tuple = operator.starcaller(f)

Ah, of course - I didn't think of the multiple arguments case, thanks :)

-Emanuel


More information about the Python-ideas mailing list