Message253428
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. |
|
Date |
User |
Action |
Args |
2015-10-25 16:55:42 | abacabadabacaba | set | recipients:
+ abacabadabacaba, rhettinger |
2015-10-25 16:55:42 | abacabadabacaba | set | messageid: <1445792142.26.0.767319041021.issue25454@psf.upfronthosting.co.za> |
2015-10-25 16:55:42 | abacabadabacaba | link | issue25454 messages |
2015-10-25 16:55:41 | abacabadabacaba | create | |
|