2013/11/14 Bruce Leban firstname.lastname@example.org:
Incidentally, since partial(x) doesn't do anything useful (why does it not raise an exception?) would the following ever be reasonable to support?
sub5 = partial(sub)(__, 5)
The advantage is that the signature of the partial function stands alone making it easier to read. That is,
def new_partial(func, args, **kwargs): if not args and not kwargs: return partial(partial, func) return partial(func, args, **kwargs)
You get this automatically for partial-as-method:
partial_sub = sub.partial sub5 = partial_sub(_, 5)
It will not happen in accident (or at least it is very unlikely) so there'll be no need for an exception; when it does happen in accident, the behavior is easily understood. You also get cleaner separation of the parameters' roles - after all, x.foo is partial(<things>).