Message272797
| Author |
ethan.furman |
| Recipients |
barry, eli.bendersky, ethan.furman, ezio.melotti, martin.panter, r.david.murray, serhiy.storchaka, veky |
| Date |
2016年08月15日.20:40:25 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1471293626.09.0.619516152275.issue23591@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
'.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. |
|