Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Unexpected behavior change in subclassingEnum class as of 3.11 #103479

Closed
Assignees
ethanfurman
Labels
docsDocumentation in the Doc dir
@sadra-barikbin

Description

@sadra-barikbin

I had a question regarding changes in subclassingEnum in 3.11. As of 3.11, if enum class has a mixin parent apart fromEnum which has defined__init__ or__new__,member._value_ is set to be another instance of the mixin class
unless user defines__new__ in the enum class and set_value_. However user naturally expects_value_ to be the value assigned to the member in class definition. In the example below

classmixin:def__init__(self):passclassCustomEnum(mixin,Enum):MEMBER="member"

CustomEnum.MEMBER is an instance of mixin andCustomEnum.MEMBER.value is another instance of it (with different id), while it was expected thatCustomEnum.MEMBER.value would be"member". What has been the rationale for this change?

By the way, this change is not noted in python docs enumeration page.

Linked PRs

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp