On 12/12/20 7:25 PM, Steven D'Aprano wrote:
> On Sat, Dec 12, 2020 at 06:00:17PM -0800, Ethan Furman wrote:
>> Enum is great! Okay, okay, my opinion might be biased. ;)
>>
>> There is one area where Enum is not great -- for a bunch of unrelated
>> values.
>
> I don't know how to interpret
On Sun, Dec 13, 2020 at 12:34:27AM -0800, Ethan Furman wrote:
[me]
> class MyValue(int, Enum):
> >... ONE = 1
> >... TWO = 2
> >...
> MyValue.TWO + 3
> >5
>
> It certainly can be abused for that, but the intended purpose of IntEnum is
> not to support math operations, but rather
On 12/12/20 7:52 PM, Steven D'Aprano wrote:
On Sat, Dec 12, 2020 at 07:01:55PM -0800, Ethan Furman wrote:
That's invalid. Duplicates allowed means:
```
class K( NamedValue):
A = 1
B = 1
```
B is not an alias for A. Presumably one has the same number with different
meaning.
On Sat, Dec 12, 2020 at 07:01:55PM -0800, Ethan Furman wrote:
> That's invalid. Duplicates allowed means:
>
> > ```
> > class K( NamedValue):
> > A = 1
> > B = 1
> > ```
> B is not an alias for A. Presumably one has the same number with different
> meaning. If that were an Enum:
>
On Sat, Dec 12, 2020 at 06:00:17PM -0800, Ethan Furman wrote:
> Enum is great! Okay, okay, my opinion might be biased. ;)
>
> There is one area where Enum is not great -- for a bunch of unrelated
> values.
I don't know how to interpret that. Surely *in practice* enums are
always going to be
On 12/12/20 6:40 PM, Guido van Rossum wrote:
unlike Enum, duplicates are allowed
What does this even mean?
```
class K( NamedValue):
A = 1
A = 2
```
That's invalid. Duplicates allowed means:
> ```
> class K( NamedValue):
> A = 1
> B = 1
> ```
B is not an alias for A.
Okay, I'll bite.
On Sat, Dec 12, 2020 at 6:00 PM Ethan Furman wrote:
> unlike Enum, duplicates are allowed
>
What does this even mean?
```
class K( NamedValues):
A = 1
A = 2
```
Why would I want that?
> unlike Enum, new values can be added after class definition
>
Sure, that points