> sub5 = partial(sub, ..., 5)I don't know why, but to me that strongly implies that I'm binding argument -1 (after 0 or more arguments, or maybe 1 or more), rather than argument 2 (after exactly 1).
>
> (At the expense of giving up the abitily to pass ellipsis to partial functions).
But that's not necessarily a bad thing. But if other people expect it to bind 2, they'll be surprised when they try it on a 3-argument (or variable-argument) function.
(And yes, I realize that mixing 1-based arg counting with python negative indices is potentially confusing. I don't think it's confusing in this particular case, but in, say, documentation for a stdlib function it could be.)0
from functools import partial, __sub5 = partial(sub, __, 5)xyz = partial(x, __, y, __, z)
xyz = partial(x, __, y, ..., z)
sub5 = partial(sub)(__, 5)
def new_partial(func, *args, **kwargs):if not args and not kwargs:return partial(partial, func)return partial(func, *args, **kwargs)