Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add reversible keys, values, items views to collections.abc builtin library #134863

Copy link
Copy link
Open
@t1m013y

Description

@t1m013y
Issue body actions

Feature or enhancement

Proposal:

I am making a class like collections.OrderedDict, and I want to make it fully reversible. When the same class inherits collections.abc.Reversible and collections.abc.Mapping and implements required methods, keys can be iterated in reversed order, but not values and items.

When I try:

reversed(MyMapping)

it works

But

reversed(MyMapping.values())
reversed(MyMapping.items())

raises TypeError: 'ValuesView' object is not reversible and TypeError: 'ItemsView' object is not reversible.

Please make collections.abc.OrderedDict's mixin methods (keys, items, values) reversible when __reversed__ is implemented in the class.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirPython modules in the Lib dirtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.