On Thu, Jan 29, 2009 at 6:12 AM, Ben North <ben at redfrontdoor.org> wrote: > Hi, > > 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: > split_comma = partial(str.split, sep = ',') [snip] > I've created a patch which adds a 'partial_right' function. The two > examples above: > > >>> import functools, math > > >>> split_comma = functools.partial_right(str.split, ',') > >>> split_comma('a,b,c') > ['a', 'b', 'c'] > > >>> log_10 = functools.partial_right(math.log, 10.0) > >>> log_10(100.0) > 2.0 Can you point to real code that this makes more readable? Collin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4