I missed the discussion on this (http://www.python.org/peps/pep-0309.html), but then 2.5 isn't out yet. I think partial() misses an important use case of method getting, for instance: lst = ['A', 'b', 'C'] lst.sort(key=partialmethod('lower')) Which sorts by lower-case. Of course you can use str.lower, except you'll have unnecessarily enforced a type (and excluded Unicode). So you are left with lambda x: x.lower(). Here's an implementation: def partialmethod(method, *args, **kw): def call(obj, *more_args, **more_kw): call_kw = kw.copy() call_kw.update(more_kw) return getattr(obj, method)(*(arg+more_args), **call_kw) return call This is obviously related to partial(). Maybe this implementation should be a classmethod or function attribute, partial.method(). -- Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
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