Flags

ppb.flags contains singletons to communicate various things.

Flags should be used like None and ... (Ellipsis):

  • compare against using is

  • Do not instantiate new instances

New flags can simply be defined by:

class MyFlag(Flag):
    "This is a flag to indicate a thing."

New classes of flags (eg mouse buttons) can be defined as:

class MyFlagType(Flag, abstract=True):
    "A group of indicators"

class MyFlag(MyFlagType):
    "This is a flag to indicate a thing."

Base classes

This is the base class for defining new flags.

class ppb.flags.Flag[source]

Inherit from Flag to make a simple flag.

Add abstract=True in the class line to make a flag type.

Metaclasses

The metaclass that makes the type hinting of flags possible.

class ppb.flags.FlagMeta(*p, abstract=False, **kw)[source]

Metaclass for Flag. You probably want that instead.