Agree. This is one of the things that I was thinking.
If partial
had a certain level of completeness, it might be possible to consider syntactic convenience for it.
There seemed to be a fair amount of desire for similar syntax in: Introduce funnel operator i,e '|>' to allow for generator pipelines - #67 by Nodd
And this could be a relatively lightweight and very convenient solution (when combined with functools.pipe
) as opposed to introducing new statement with complex syntax, while maintaining almost same level of brevity and generally would look very similar.
After all, partial
is kinda curry, just lacks convenience for it. E.g.:
class curry:
def __init__(self, func, *args, **kwds):
if args or kwds:
func = partial(func, *args, **kwds)
self.func = self._ = func
def __call__(self, *args, **kwds):
return type(self)(self.func, *args, **kwds)
def __ror__(self, other):
return self.func(other)
g = curry(lambda a, b, c, d=4: a - b - c - d)
g(1)(2)(3)._(d=0) # -4