Is there a Python class/enum for flag/bit mask operations?

Python 3.6 has added Flag and IntFlag which support the usual bit-wise operations. As a bonus, the resulting values from the bit-wise operations are still members of the original flag class, and are singletons [1].

The aenum library also has this addition and is usable back to Python 2.7.

[1] A bug exists in 3.6.0: if the pseudo-flag members are being created in threads then there is no guarantee that you won’t end up with duplicates; this is fixed in 3.6.1 (and never existed in aenum).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)