New submission from Ethan Furman <[email protected]>:
Due to the nature of `str`, if an Enum tries to mixin the str type, all of it's
members will be strings -- even if they didn't start out that way:
class MyStrEnum(str, Enum):
tuple = 'oops',
okay = 'correct'
>>> list(MyStrEnum)
[<MyStrEnum.tuple: "('oops',)">, MyStrEnum.okay: 'correct'>]
The StrEnum class will have a check to ensure that each value was already a
string, or can be converted to a string via
str(bytes, encoding, errors)
----------
assignee: ethan.furman
components: Library (Lib)
messages: 377186
nosy: barry, eli.bendersky, ethan.furman, serhiy.storchaka, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: need StrEnum in enum.py
type: enhancement
versions: Python 3.10
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41816>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com