Why IterableUserDict?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Sep 19 01:26:58 EDT 2010


On Sat, 18 Sep 2010 09:42:14 +0200, Peter Otten wrote:

[...]
>> Now that boggles my brain. Why was support for iteration added as a
>> subclass, instead of simply adding the __iter__ method to UserDict?
>> UserDict is supposed to be a drop-in replacement for dict (although the
>> use-cases for it are much fewer now that we can inherit from dict), so
>> it doesn't make sense to me to have a non-iterable UserDict plus a
>> subclass which is iterable.
>> 
>> Can anyone shed any light on this apparently bizarre design decision?
> 
> I looked it up for you:
> 
> http://svn.python.org/view/python/trunk/Lib/UserDict.py?view=log
[...]
> The bug report is also interesting:
> 
> http://bugs.python.org/issue448153

Oh my.

Guido is more forgiving than me. I would have left __iter__ in UserDict 
and treated the bug report as a "will not fix".


Thanks for that.


-- 
Steven



More information about the Python-list mailing list