[Python-Dev] Re: name for new Enum decorator

2021-06-08 Thread Stephen J. Turnbull
Irit Katriel via Python-Dev writes: > Andrei is suggesting to look at each enum value as the set of "bits set to > 1" in this value, and then apply a set-thoery term to the problem. > [...] Anyway, I don't know whether this kind of terminology is > widely accessible. I think the everyday

[Python-Dev] Re: name for new Enum decorator

2021-06-07 Thread Irit Katriel via Python-Dev
Andrei is suggesting to look at each enum value as the set of "bits set to 1" in this value, and then apply a set-thoery term to the problem. A set of "cardinality 1" in this context is an enum value with only one "1", what you called canonical. The condition you defined is that any bit that is

[Python-Dev] Re: name for new Enum decorator

2021-06-07 Thread Andrei Kulakov
On Mon, Jun 7, 2021 at 1:36 PM Ethan Furman wrote: > On 6/6/21 9:14 AM, Irit Katriel via Python-Dev wrote: > > On 6 Jun 2021, at 16:58, Andrei Kulakov wrote: > > >> In Math / CompSci there is a definition that almost exactly matches > this: Exact Cover - > >>

[Python-Dev] Re: name for new Enum decorator

2021-06-07 Thread Ethan Furman
On 6/6/21 9:14 AM, Irit Katriel via Python-Dev wrote: > On 6 Jun 2021, at 16:58, Andrei Kulakov wrote: >> In Math / CompSci there is a definition that almost exactly matches this: Exact Cover - >> https://en.wikipedia.org/wiki/Exact_cover >> >> The difference is that, IIRC, solving the problem

[Python-Dev] Re: name for new Enum decorator

2021-06-06 Thread Irit Katriel via Python-Dev
 > On 6 Jun 2021, at 16:58, Andrei Kulakov wrote: > > > In Math / CompSci there is a definition that almost exactly matches this: > Exact Cover - https://en.wikipedia.org/wiki/Exact_cover > > The difference is that, IIRC, solving the problem is finding and removing all > subsets that are

[Python-Dev] Re: name for new Enum decorator

2021-06-06 Thread Andrei Kulakov
On Thu, May 27, 2021 at 11:31 PM Ethan Furman wrote: > Greetings! > > The Flag type in the enum module has had some improvements, but I find it > necessary to move one of those improvements > into a decorator instead, and I'm having a hard time thinking up a name. > > What is the behavior?

[Python-Dev] Re: name for new Enum decorator

2021-06-06 Thread Steve Holden
On Fri, May 28, 2021 at 10:26 PM Ethan Furman wrote: > On 5/28/21 12:43 AM, Petr Viktorin wrote: > > On 28. 05. 21 5:24, Ethan Furman wrote: > > >> class FlagWithMasks(IntFlag): > >> DEFAULT = 0x0 > >> > >> FIRST_MASK = 0xF > >> FIRST_ROUND = 0x0 > >>

[Python-Dev] Re: name for new Enum decorator

2021-06-03 Thread Chris Jerdonek
On Wed, Jun 2, 2021 at 8:04 PM Ethan Furman wrote: > > Thank you everyone for your ideas! Instead of adding another > single-purpose decorator, I'm toying with the idea of > adding a general purpose decorator that accepts instructions. Something > along the lines of: > ... > Thoughts? > I had

[Python-Dev] Re: name for new Enum decorator

2021-06-02 Thread Glenn Linderman
On 6/2/2021 7:59 PM, Ethan Furman wrote: On 5/27/21 8:24 PM, Ethan Furman wrote: > So, like the enum.unique decorator that can be used when duplicate names should be an error, > I'm adding a new decorator to verify that a Flag has no missing aliased values that can be > used when the

[Python-Dev] Re: name for new Enum decorator

2021-06-02 Thread Ethan Furman
On 5/27/21 8:24 PM, Ethan Furman wrote: > So, like the enum.unique decorator that can be used when duplicate names should be an error, > I'm adding a new decorator to verify that a Flag has no missing aliased values that can be > used when the programmer thinks it's appropriate... but I have

[Python-Dev] Re: name for new Enum decorator

2021-06-02 Thread Chris Jerdonek
On Thu, May 27, 2021 at 8:30 PM Ethan Furman wrote: > But what if we have something like: > > class Color(Flag): > RED = 1# 0001 > BLUE = 4 # 0100 > WHITE = 7 # 0111 > > As you see, WHITE is an "alias" for a value that does not exist

[Python-Dev] Re: name for new Enum decorator

2021-05-31 Thread Glenn Linderman
On 5/31/2021 1:37 PM, Luciano Ramalho wrote: On Fri, May 28, 2021 at 7:00 PM Joao S. O. Bueno wrote: "check_all_bits_defined" or something along it. Best suggestion so far. Similar: "ensure_all_bits_named" I am all for brainstorming, as we've been doing for a few days. Maybe we need to

[Python-Dev] Re: name for new Enum decorator

2021-05-31 Thread Luciano Ramalho
On Fri, May 28, 2021 at 7:00 PM Joao S. O. Bueno wrote: > "check_all_bits_defined" or something along it. Best suggestion so far. Similar: "ensure_all_bits_named" I am all for brainstorming, as we've been doing for a few days. Maybe we need to brainstorm some more. I just don't think the goal

[Python-Dev] Re: name for new Enum decorator

2021-05-30 Thread Barney Gale
+1 on 'complete'. If 'enum.unique()' means 'every value has at most one name', then perhaps `enum.complete()` can mean 'every value has at least one name'? Or is that not accurate? Other suggestions: 'occupied', 'full', 'exhaustive'. Barney On Mon, 31 May 2021 at 00:02, Jeff Allen wrote: >

[Python-Dev] Re: name for new Enum decorator

2021-05-30 Thread Jeff Allen
On 28/05/2021 04:24, Ethan Furman wrote: The flags RED, GREEN, and BLUE are all canonical, while PURPLE and WHITE are aliases for certain flag combinations.  But what if we have something like:     class Color(Flag):     RED = 1    # 0001     BLUE = 4   # 0100    

[Python-Dev] Re: name for new Enum decorator

2021-05-29 Thread Glenn Linderman
On 5/29/2021 6:33 PM, Nick Coghlan wrote: On Sat, 29 May 2021, 7:27 am Ethan Furman, > wrote: On 5/28/21 12:43 AM, Petr Viktorin wrote:  > On 28. 05. 21 5:24, Ethan Furman wrote:  >>      class FlagWithMasks(IntFlag):  >>          DEFAULT = 0x0  

[Python-Dev] Re: name for new Enum decorator

2021-05-29 Thread Nick Coghlan
On Sat, 29 May 2021, 7:27 am Ethan Furman, wrote: > On 5/28/21 12:43 AM, Petr Viktorin wrote: > > On 28. 05. 21 5:24, Ethan Furman wrote: > > >> class FlagWithMasks(IntFlag): > >> DEFAULT = 0x0 > >> > >> FIRST_MASK = 0xF > >> FIRST_ROUND = 0x0 > >>

[Python-Dev] Re: name for new Enum decorator

2021-05-28 Thread Joao S. O. Bueno
I think a longer-named decorator, with a name that actually describes its behavior would be better than any smart short name in this case. "check_all_bits_defined" or something along it. On Fri, 28 May 2021 at 18:30, Ethan Furman wrote: > On 5/28/21 12:43 AM, Petr Viktorin wrote: > > On 28.

[Python-Dev] Re: name for new Enum decorator

2021-05-28 Thread Ethan Furman
On 5/28/21 12:43 AM, Petr Viktorin wrote: > On 28. 05. 21 5:24, Ethan Furman wrote: >> class FlagWithMasks(IntFlag): >> DEFAULT = 0x0 >> >> FIRST_MASK = 0xF >> FIRST_ROUND = 0x0 >> FIRST_CEIL = 0x1 >> FIRST_TRUNC = 0x2 >> >> SECOND_MASK

[Python-Dev] Re: name for new Enum decorator

2021-05-28 Thread Glenn Linderman
On 5/28/2021 12:08 AM, Michał Górny wrote: On Thu, 2021-05-27 at 20:24 -0700, Ethan Furman wrote: Greetings! The Flag type in the enum module has had some improvements, but I find it necessary to move one of those improvements into a decorator instead, and I'm having a hard time thinking up a

[Python-Dev] Re: name for new Enum decorator

2021-05-28 Thread Petr Viktorin
On 28. 05. 21 5:24, Ethan Furman wrote: Greetings! The Flag type in the enum module has had some improvements, but I find it necessary to move one of those improvements into a decorator instead, and I'm having a hard time thinking up a name. What is the behavior?  Well, a name in a flag

[Python-Dev] Re: name for new Enum decorator

2021-05-28 Thread Michał Górny
On Thu, 2021-05-27 at 20:24 -0700, Ethan Furman wrote: > Greetings! > > The Flag type in the enum module has had some improvements, but I find it > necessary to move one of those improvements > into a decorator instead, and I'm having a hard time thinking up a name. > > What is the behavior?

[Python-Dev] Re: name for new Enum decorator

2021-05-27 Thread Jonathan Goble
On Thu, May 27, 2021 at 11:34 PM Ethan Furman wrote: > So, like the enum.unique decorator that can be used when duplicate names > should be an error, I'm adding a new decorator > to verify that a Flag has no missing aliased values that can be used when > the programmer thinks it's appropriate...