Ethan Furman added the comment:

'.0' does not have a name unless the user defines it; similarly, '.-1' does not 
have a name unless the user defines it.

For Flags, negative numbers are supported in order to specify which flags are 
desired, but the final representation will be zero or positive:

>>> class Hah(enum.Flags):
...   this, that, these, those, thuse
... 
>>> Hah(0)
<Hah: 0>
>>> Hah(-1)
<Hah.this|that|these|those|thuse: 31>

The algorithm is simple: start with the biggest Flag and mask off matching bits 
until all bits are are matched.  If any unmatched bits remain an error is 
raised.

If a user does horrible things like your Weird class then any breakage is on 
them.

As it stands, Weird(7) would be <Weird.A|BC: 7>, and if A was not defined an 
error would be raised.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23591>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to