Evgeny Kapun added the comment:

There are methods that accept a single argument and behave like a binary 
operation or a predicate. It would be useful to be able to turn them into 
binary functions for use with higher-order functions like map and reduce:

    reduce(methodcaller("combine"), objs) # reduce a sequence using "combine" 
method
    map(methodcaller("combine"), alist, blist) # combine pairs of elements
    all(map(methodcaller("compatible_with"), alist, blist)) # check that pairs 
of elements are compatible

This functionality is already available for overloaded operators, because 
operator module provides them as functions. Some methods behave similarly to 
operators, so I think that a similar functionality should be available for them 
as well.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25454>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to