[Python-ideas] defaultattrgetter

John O'Connor jxo6948 at rit.edu
Thu Dec 22 08:05:01 CET 2011

On Wed, Dec 21, 2011 at 6:33 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Why create a new function for it? Why not just give attrgetter a keyword
> only argument default?

I need to revise my example. It should be:
_x = defaultattrgetter(('x', 0))
_xy = defaultattrgetter(('x', 0), ('y', 1))

Which is what I had originally but I was too quick to change it in the
course of writing thinking the dict notation looked cleaner. But,
since the argument order matters a dict wont work. The same applies to
using keyword arguments. I'm not sure if there is a clean way to add
this type of functionally to attrgetter without strings being a
special case.

More information about the Python-ideas mailing list