SIGN IN SIGN UP

bpo-43945: [Enum] Deprecate non-standard mixin format() behavior (GH-25649)

In 3.12 the enum member, not the member's value, will be used for
format() calls.  Format specifiers can be used to retain the current
display of enum members:

Example enumeration:

    class Color(IntEnum):
        RED = 1
        GREEN = 2
        BLUE = 3

Current behavior:

    f'{Color.RED}'  -->  '1'

Future behavior:

    f'{Color.RED}'  --> 'RED'

Using d specifier:

    f'{Color.RED:d}'  --> '1'

Using specifiers can be done now and is future-compatible.
E
Ethan Furman committed
5987b8c463892e0ab7a63cdae92f34b5eb79732d
Parent: cfe523b
Committed by GitHub <noreply@github.com> on 4/27/2021, 5:42:57 AM