[plum.int.flag] Module Reference

Interpret bytes as an integer with bit flags.

class plum.int.flag.Flag(value)

Interpret bytes as an integer with bit flag enumerations.

Parameters:
  • x (number or str) – value
  • base (int) – base of x when x is str
class plum.int.flag.FlagType(name, bases, namespace, nbytes=None, byteorder=None, source=None)

Integer flag type metaclass.

Create custom Flag subclass.

Parameters:
  • nbytes (int) – number of bytes
  • byteorder (str) – 'big' or 'little'
  • source (EnumMeta) – enumeration to copy

For example:

>>> from plum.int.flag import Flag
>>> class MyFlags(Flag, nbytes=1, byteorder='little'):
...     RED = 1
...     GREEN = 2
...     BLUE = 4
...
>>>