Message272797
'.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. |
|
Date |
User |
Action |
Args |
2016-08-15 20:40:26 | ethan.furman | set | recipients:
+ ethan.furman, barry, ezio.melotti, r.david.murray, eli.bendersky, martin.panter, serhiy.storchaka, veky |
2016-08-15 20:40:26 | ethan.furman | set | messageid: <1471293626.09.0.619516152275.issue23591@psf.upfronthosting.co.za> |
2016-08-15 20:40:26 | ethan.furman | link | issue23591 messages |
2016-08-15 20:40:25 | ethan.furman | create | |
|