[Python-ideas] defaultattrgetter

Stefan Behnel stefan_ml at behnel.de
Thu Dec 22 09:35:42 CET 2011

Masklinn, 22.12.2011 09:25:
> On 2011-12-22, at 09:09 , Stefan Behnel wrote:
>>> What if you need a default value for one but not the others, or different values for all three? Does this behavior really make sense?
>> What would be the use case? Would you want the lookup process to continue on the default argument if an intermediate attribute is not found? And if a subsequent lookup fails? Take the corresponding default value again and keep looking up on it? That feels rather unpredictable from a users' point of view.
> A multiple-*args attrgetter fetches different arguments, for a "lookup process" you need a dotted path (attrgetter('foo.bar.baz')).

Ah, thanks, I remembered that incorrectly then.

In that case, I vote -1 for adding the feature in the first place, because 
it would complicate an otherwise simple API too much and the current syntax 
proposals are too verbose and too hard to read.


More information about the Python-ideas mailing list