Behavior of auto in Enum and Flag.

Oren Ben-Kiki python-oren at ben-kiki.org
Mon Apr 3 13:01:29 EDT 2017


On Mon, Apr 3, 2017 at 7:43 PM, Chris Angelico <rosuav at gmail.com> wrote:

> Here's a counter-example that supports the current behaviour:
>
> >>> from enum import IntFlag, auto
> >>> class Spam(IntFlag):
> ...     FOO = auto()
> ...     BAR = auto()
> ...     FOOBAR = FOO | BAR
> ...     SPAM = auto()
> ...     HAM = auto()
> ...     SPAMHAM = SPAM | HAM
> ...
>

Ugh, good point - I didn't consider that use case, I see how it would be
nasty to implement.

I guess just improving the documentation is called for, then...

Thanks,

Oren.


More information about the Python-list mailing list