diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2021-03-31 04:17:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 04:17:26 (GMT) |
commit | b775106d940e3d77c8af7967545bb9a5b7b162df (patch) | |
tree | a5146740d7fab61a70bf410e4f348a9525cb1fd4 /Misc | |
parent | 51a85ddce8b336addcb61b96f04c9c5edef07296 (diff) | |
download | cpython-b775106d940e3d77c8af7967545bb9a5b7b162df.zip cpython-b775106d940e3d77c8af7967545bb9a5b7b162df.tar.gz cpython-b775106d940e3d77c8af7967545bb9a5b7b162df.tar.bz2 |
bpo-40066: Enum: modify `repr()` and `str()` (GH-22392)
* Enum: streamline repr() and str(); improve docs
- repr() is now ``enum_class.member_name``
- stdlib global enums are ``module_name.member_name``
- str() is now ``member_name``
- add HOW-TO section for ``Enum``
- change main documentation to be an API reference
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-09-23-21-58-34.bpo-40066.f1dr_5.rst | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-03-25-21-26-30.bpo-40066.7EBQ3_.rst | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2020-09-23-21-58-34.bpo-40066.f1dr_5.rst b/Misc/NEWS.d/next/Library/2020-09-23-21-58-34.bpo-40066.f1dr_5.rst new file mode 100644 index 0000000..6d2c68e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-09-23-21-58-34.bpo-40066.f1dr_5.rst @@ -0,0 +1,4 @@ +Enum's `repr()` and `str()` have changed: `repr()` is now *EnumClass.MemberName* +and `str()` is *MemberName*. Additionally, stdlib Enum's whose contents are +available as module attributes, such as `RegexFlag.IGNORECASE`, have their +`repr()` as *module.name*, e.g. `re.IGNORECASE`. diff --git a/Misc/NEWS.d/next/Library/2021-03-25-21-26-30.bpo-40066.7EBQ3_.rst b/Misc/NEWS.d/next/Library/2021-03-25-21-26-30.bpo-40066.7EBQ3_.rst new file mode 100644 index 0000000..11903f8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-03-25-21-26-30.bpo-40066.7EBQ3_.rst @@ -0,0 +1,3 @@ +Enum: adjust ``repr()`` to show only enum and member name (not value, nor +angle brackets) and ``str()`` to show only member name. Update and improve +documentation to match. |