Skip to content

Conversation

@ethanfurman
Copy link
Member

@ethanfurman ethanfurman commented Mar 31, 2021

non-StrEnum `__str__` will print the member name
StrEnum `__str__` will print the member value
create enum._stdlib_enum decorator for Enums created the normal way: it
adjusts `__repr__` and `__str__` to be the same as if the Enum had been
created using `_convert_`

update various modules to use the new decorator
if `enum.__str__` is either `Enum.__str__` or `global_enum_str` use the
value's `__format__`
repr() = class.member_name
str() = member_name
rename to `global_enum` and have `global_enum` update the module's
namespace with the members

remove `_stdlib_enum` where the enums were not being exported to the
module's namespace
* rename global_int_repr --> global_enum_repr
* adjust global_flag_repr to print hex number for out-of-range values
* extract function when _generate_next_value_ is a static method
- repr() is now ``enum_class.member_name``
- str() is now ``member_name``
- add HOW-TO section for ``Enum``
- change main documentation to be an API reference
@ethanfurman ethanfurman requested a review from tiran as a code owner March 31, 2021 14:31
@ethanfurman ethanfurman changed the title Enum global repr doctest bpo-40066: Enum global repr doctest Mar 31, 2021
@ethanfurman ethanfurman deleted the enum-global_repr-doctest branch March 31, 2021 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants