Re: [Python-ideas] Optional kwarg making attrgetter & itemgetter always return a tuple

On Sep 14, 2012 10:02 PM, "Jim Jewett" <jimjjewett@gmail.com> wrote:
On 9/14/12, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:
I can see why you would expect different behaviour here, though. I tend
not
To be clear, I wasn't complaining about the inconvenience of importing and referring to attrgetter. I was saying that if the obvious alternative (lambda functions) is at least as convenient then it's odd to describe itemgetter/attrgetter as convenience functions.
2) using lambda
I disagree here. I find the fact that a lambda function shows me the expression I would normally use to get the quantity I'm interested in makes it easier for me to read. When I look at it I don't see it as a callable function but as an expression that I'm passing for use somewhere else.
In general it is bad to conflate scalar/sequence semantics so that a
caller
You can extend an API to support sequences by adding a new entry point. This is a common idiom in python: think list.append vs list.extend. Oscar
participants (1)
-
Oscar Benjamin