22 Dec
2011
22 Dec
'11
7:05 a.m.
On Wed, Dec 21, 2011 at 6:33 PM, Steven D'Aprano <steve@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.