Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum: More changes for 3.11 #7862

Merged
merged 3 commits into from
May 19, 2022
Merged

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented May 18, 2022

In 3.11+, enum.Flags are iterable and sized:

C:\Users\alexw\coding\cpython>python
Running Debug|x64 interpreter...
Python 3.12.0a0 (main, May 17 2022, 16:54:26) [MSC v.1931 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from enum import *
>>> class Foo(Flag):
...     X = 1
...     Y = 2
...     Z = X | Y
...
>>> len(Foo.X)
1
>>> len(Foo.Z)
2
>>> list(Foo.X)
[<Foo.X: 1>]
>>> list(Foo.Z)
[<Foo.X: 1>, <Foo.Y: 2>]

CPython changes:

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 04dde4d into python:master May 19, 2022
@AlexWaygood AlexWaygood deleted the enum311 branch May 19, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants