Vedran Čačić added the comment:
Now that I actually had the chance to play with the implementation, I see most
of my worst fears were justified. :-( Look:
>>> import enum
>>> class B(enum.Flag):
b = 3
c = 4
d = 6
>>> B.b | B.c
Traceback (most recent call last): ...
ValueError: 7 is not a valid B
>>> t = B.b | B.c
>>> t
<B.d|1: 7>
>>> B.b | B.c
>>> B.b | B.c
<B.d|1: 7>
>>> ~B.d
<B.0: 0>
Do you really find this behavior acceptable?? I see at least three bugs here.
At least you did say in the documentation
> Individual flags should have values that are powers of two (1, 2, 4, 8, ...)
but it seems to me it's not prominent enough.
---
Also, auto, despite parentheses, works exactly as it shouldn't.
>>> class C(enum.Enum):
a = b = enum.auto()
>>> C.a
<C.a: 1>
>>> C.b
<C.b: 2>
>>> def f():
return enum.auto()
>>> class E(enum.Enum):
a = b = f()
c = d = 2
>>> E.a is E.b
False
>>> E.c is E.d
True
>>> E.b is E.c
True
In my opinion, this is simply horrible. Even _you_ said
(http://bugs.python.org/issue23591#msg275093) this would be unacceptable. I'm
really, really sad.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23591>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com