Python class enum Flag














































Python class enum Flag



Members of Flag class be combined through bitwise operators (&, |, ^, ~) provided, they cannot be combined with, nor compared against, any other Flag enumeration or Integer enumeration. A False is returned if a combination of Flag members results in no flags being set.
The following code snippet illustrates the condition. When the names A and B are set to auto() as values and AND operation is performed, the flag is set to False. The value of enumeration class section can be anything as the instances of auto() is used.

The flag is set to True when both the values of the enum names are set to a value such as illustrate by the code snippet below. In order to obtain Boolean operation, the values are set in integers.


Comments