[issue14384] Add "default" kw argument to operator.itemgetter and operator.attrgetter

R. David Murray report at bugs.python.org
Thu Mar 22 02:35:33 CET 2012


R. David Murray <rdmurray at bitdance.com> added the comment:

Thanks for the suggestion. 

It is an interesting idea, but there are some issues.  attrgetter and itemgetter can take more than one key.  It would probably make more sense to have the returned function be the one that takes the default, but in that case you might as well just use getattr.  If we did accept a keyword-only argument for a default, what does the default mean if there is more than one key?  And what if there are dotted names in the attrgetter keys?

I'm inclined to reject this as too complex for a marginal a use case.  But perhaps a python-ideas discussion would be appropriate.

----------
nosy: +r.david.murray
type:  -> enhancement
versions:  -Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14384>
_______________________________________


More information about the Python-bugs-list mailing list