This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add "methodcaller" to the operator module
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: collinwinter, georg.brandl, gregory_p, rhettinger
Priority: normal Keywords:

Created on 2006-06-14 16:02 by gregory_p, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
methodcaller.diff georg.brandl, 2008-01-20 15:16 methodcaller patch
Messages (5)
msg54822 - (view) Author: Gregory Petrosyan (gregory_p) Date: 2006-06-14 16:02
I found that I (like Alex Martelli, http://mail.python.
org/pipermail/python-dev/2006-February/060341.html :-) 
am writing lambdas like "lambda x: x.do_smth(a,b,c)" a 
lot (often for filter/map functions). So, I think it 
would be great to have such a function implemented in 
C and placed in the standart library. Operator module 
can be a good place for it.

--
Regards, Gregory.
msg54823 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-03-30 14:39
Guido has stated that lambda will not be removed in Python 3000 (see PEP 3099), so I can't see the need for a HOF to avoid lambda-usage, especially when the lambda expression is shorter/clearer:

operator.methodcaller('method', x, y, z)
lambda x: x.method(x, y, z)
msg54824 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-03-30 16:46
Re-opening.  There are valid use cases for this request and there are some speed benefits to having a functional form.
msg61305 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-01-20 15:16
Attaching patch against SVN trunk.
msg62835 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-02-23 23:05
Committed patch as r61028.
History
Date User Action Args
2022-04-11 14:56:18adminsetgithub: 43497
2008-02-23 23:05:10georg.brandlsetstatus: open -> closed
assignee: rhettinger -> georg.brandl
resolution: accepted
messages: + msg62835
2008-01-20 15:16:15georg.brandlsetfiles: + methodcaller.diff
assignee: rhettinger
resolution: rejected -> (no value)
messages: + msg61305
nosy: + georg.brandl
2006-06-14 16:02:40gregory_pcreate