We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In 3.10, since StrEnum is not yet provided, I thought to emulate it by simply using str as a mixin:
StrEnum
str
>>> from enum import Enum >>> class x(str, Enum): ... KEY = 'value' ...
The result seems mostly correct, but there is an inconsistency between various ways of converting the instance to an ordinary string:
>>> isinstance(x.KEY, str) True >>> '%s' % x.KEY 'x.KEY' >>> f'{x.KEY}' 'value' >>> '{}'.format(x.KEY) 'value' >>> str(x.KEY) 'x.KEY'
Compare in 3.11, which is consistent when using this mixin approach:
>>> from enum import Enum >>> class x(str, Enum): ... KEY = 'value' ... >>> isinstance(x.KEY, str) True >>> '%s' % x.KEY 'x.KEY' >>> f'{x.KEY}' 'x.KEY' >>> '{}'.format(x.KEY) 'x.KEY' >>> str(x.KEY) 'x.KEY'
And consistent the other way when using the new StrEnum:
>>> from enum import StrEnum >>> class x(StrEnum): ... KEY = 'value' ... >>> isinstance(x.KEY, str) True >>> '%s' % x.KEY 'value' >>> f'{x.KEY}' 'value' >>> '{}'.format(x.KEY) 'value' >>> str(x.KEY) 'value'
I don't have a firm opinion on which is correct, but I don't think it should depend on the conversion method.
3.10
No response
The text was updated successfully, but these errors were encountered:
3.10 and 3.11 are security-only versions, so we couldn't change anything there even if we wanted to.
Sorry, something went wrong.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
In 3.10, since
StrEnum
is not yet provided, I thought to emulate it by simply usingstr
as a mixin:The result seems mostly correct, but there is an inconsistency between various ways of converting the instance to an ordinary string:
Compare in 3.11, which is consistent when using this mixin approach:
And consistent the other way when using the new
StrEnum
:I don't have a firm opinion on which is correct, but I don't think it should depend on the conversion method.
CPython versions tested on:
3.10
Operating systems tested on:
No response
The text was updated successfully, but these errors were encountered: