Inconsistency between dict() and collections.OrderedDict() methods.

breamoreboy at gmail.com breamoreboy at gmail.com
Sat Apr 29 22:53:13 EDT 2017


On Sunday, April 30, 2017 at 2:30:25 AM UTC+1, Erik wrote:
> On 30/04/17 01:17, breamoreboy wrote:
> > On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
> >> The other is that the documentation of collections.OrderedDict seems to
> >> be lacking (it is talking in terms of being a "dict" subclass, but it
> >> actually isn't one).
> >>
> >> E.
> >
> > Could have fooled me.
> >
> > C:\python
> > Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> from collections import OrderedDict
> >>>> o = OrderedDict()
> >>>> isinstance(o, dict)
> > True
> 
> OK, so technically it is a subclass, I didn't notice that, but where 
> does the documentation explain all of the differences in behaviour? It 
> doesn't. It states "it's a subclass of dict that does <this> and <that>" 
> (by which I mean "order the keys") and it's not unreasonable to 
> therefore believe that's _all_ it does differently. If if it actually 
> does "<this>, <that>, <the other>, <something>, <foo>" (by which I mean 
> "order the keys and implement very different behavior for other methods 
> such as __init__ and __update__") then the documentation is lacking 
> (because it doesn't mention it). Isn't that what I said?
> 
> E.

So provide a documentation patch on the bug tracker.

Once you've done that how about subclassing UserDict https://docs.python.org/3.5/library/collections.html#collections.UserDict, pinching any code from OrderedDict as needed?

Kindest regards.

Mark Lawrence.



More information about the Python-list mailing list