[Python-Dev] Partial function application 'from the right' (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Thu Jan 29 18:58:44 CET 2009


Hello,

Ben North <ben redfrontdoor.org> writes:

I find 'functools.partial' useful, but occasionally I'm unable to use it because it lacks a 'from the right' version. E.g., to create a function which splits a string on commas, you can't say # Won't work when called: splitcomma = partial(str.split, sep = ',')

In py3k, we could also use "..." (the Ellipsis object) to denote places where an argument is missing, so that:

split_comma = partial(str.split, ..., ',')

would do what you want.

Regards

Antoine.



More information about the Python-Dev mailing list