Skip to content

Misleading docstring in OrderedDict example #141721

@ramalho

Description

@ramalho

Documentation

Here is the first example in OrderedDict Examples and Recipes:

class LastUpdatedOrderedDict(OrderedDict):
    'Store items in the order the keys were last added'

    def __setitem__(self, key, value):
        super().__setitem__(key, value)
        self.move_to_end(key)

As the name of the class states, when a key is updated, it is moved to the end. But the docstring mentions "keys were last added", which is the standard behavior of OrderedDict, while LastUpdatedOrderedDict overrides __setitem__ to move keys when they are updated.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc direasy

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions