[Python-Dev] Missing operator.call (original) (raw)
Andrew Bennetts andrew-pythondev at puzzling.org
Wed Feb 4 14:28:21 CET 2009
- Previous message: [Python-Dev] Missing operator.call
- Next message: [Python-Dev] Missing operator.call
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hrvoje Niksic wrote:
Is there a reason why the operator module doesn't have an operator.call function?
Python 2.6 adds operator.methodcaller. So you could use operator.methodcaller('call'), but that's not really any better than lambda x: x().
A patch to add operator.caller(*args, **kwargs) may be a good idea. Your example would then be:
map(operator.caller(), lst)
That reads ok to me. I think this reads better though:
[callable() for callable in lst]
-Andrew.
- Previous message: [Python-Dev] Missing operator.call
- Next message: [Python-Dev] Missing operator.call
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]