12.03.21 23:48, Ethan Furman пише:
> A question that comes up quite a bit on Stackoverflow is how to test to
> see if a value will result in an Enum member, preferably without having
> to go through the whole try/except machinery.
>
> A couple versions ago one could use a containment check:
>
>
A suggestion for ease of extension in the future: replace `field` parameter
`kw_only` with `init_type`.
As `field` is expected to be used less than `_: dataclasses.KW_ONLY` and
`dataclass(kw_only=True)`, it can afford to be more verbose. On top of that, if
you want to add positional-only fields
On Wed, Mar 17, 2021, 5:34 AM Serhiy Storchaka wrote:
> 12.03.21 23:48, Ethan Furman пише:
> > A question that comes up quite a bit on Stackoverflow is how to test to
> > see if a value will result in an Enum member, preferably without having
> > to go through the whole try/except machinery.
> >
On 3/17/2021 8:07 AM, Laurie O wrote:
A suggestion for ease of extension in the future: replace `field` parameter
`kw_only` with `init_type`.
As `field` is expected to be used less than `_: dataclasses.KW_ONLY` and
`dataclass(kw_only=True)`, it can afford to be more verbose. On top of that, if
I've created https://bugs.python.org/issue43532 for this. PR is
https://github.com/python/cpython/pull/24909. I still need to add a few
more tests and update the documentation.
Eric
On 3/15/2021 5:18 PM, Eric V. Smith wrote:
[I'm sort of loose with the terms field, parameter, and argument here