[Python-ideas] Re: Enum: determining if a value is valid

2021-03-17 Thread Serhiy Storchaka
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: > >  

[Python-ideas] Re: dataclasses keyword-only fields, take 2

2021-03-17 Thread Laurie O
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

[Python-ideas] Re: Enum: determining if a value is valid

2021-03-17 Thread Ricky Teachey
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. > >

[Python-ideas] Re: dataclasses keyword-only fields, take 2

2021-03-17 Thread Eric V. Smith
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

[Python-ideas] Re: dataclasses keyword-only fields, take 2

2021-03-17 Thread Eric V. Smith
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