[Python-Dev] any support for a methodcaller HOF?
Giovanni Bajo
rasky at develer.com
Fri Feb 3 15:47:05 CET 2006
More information about the Python-Dev mailing list
Fri Feb 3 15:47:05 CET 2006
- Previous message: [Python-Dev] any support for a methodcaller HOF?
- Next message: [Python-Dev] any support for a methodcaller HOF?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nick Coghlan <ncoghlan at gmail.com> wrote: > Consider these comparisons: > > itemgetter(1) <=> (x[1] def (x)) > attrgetter('foo') <=> (x.foo def (x)) > partial(y, arg) <=> (y(arg) def) > > So rather than yet another workaround for lambda being ugly, I'd rather see > a PEP that proposed "Let's make the syntax for deferring an expression not > be ugly anymore, now that we have generator expressions and conditionals as > an example of how to do it right". +1000. Instead of keep on adding arcane functions which return objects which (when called) do things not obvious if not by knowing the function beforehand, a generic syntax should be added for deferred execution. I too use itemgetter and friends but the "correct" way of doing a defferred "x[1]" *should* let you write "x[1]" in the code. This is my main opposition to partial/itemgetter/attrgetter/methodcaller: they allow deferred execution using a syntax which is not equivalent to that of immediate execution. Unless we propose to deprecate "x[1]" in favor of "itemgetter(1)(x)"... -- Giovanni Bajo
- Previous message: [Python-Dev] any support for a methodcaller HOF?
- Next message: [Python-Dev] any support for a methodcaller HOF?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list