Part of twisted.python.constants View Source View In Hierarchy
Known subclasses: twisted.python.constants.Names, twisted.python.constants.Values
_ConstantsContainer
is a class with attributes used as symbolic constants. It is up to
subclasses to specify what kind of constants are allowed.| Class Variables | _constantType | Specified by a _ConstantsContainer
subclass to specify the type of constants allowed by that subclass.
|
| _enumerantsInitialized | A bool tracking whether _enumerants has been
initialized yet or not.
| |
| _enumerants | A dict mapping the names of constants (eg NamedConstant
instances) found in the class definition to those instances. This is
initialized via the _EnumerantsInitializer
descriptor the first time it is accessed.
|
| Method | __new__ | Classes representing constants containers are not intended to be instantiated. |
| Class Method | lookupByName | Retrieve a constant by its name or raise a ValueError if
there is no constant associated with that name. |
| Class Method | iterconstants | Iteration over a Names subclass
results in all of the constants it contains. |
| Class Method | _initializeEnumerants | Find all of the NamedConstant
instances in the definition of cls, initialize them with
constant values, and build a mapping from their names to them to attach to
cls. |
| Class Method | _constantFactory | Construct the value for a new constant to add to this container. |
The class object itself is used directly.
NamedConstant
instances in the definition of cls, initialize them with
constant values, and build a mapping from their names to them to attach to
cls.| Parameters | name | The name of the constant to create. |
| Returns | NamedConstant
instances have no value apart from identity, so return a meaningless dummy
value.
| |
ValueError if
there is no constant associated with that name.| Parameters | name | A str giving the name of one of the constants defined by
cls.
|
| Returns | The NamedConstant
associated with name.
| |
| Raises | ValueError | If name is not the name of one of the constants defined by
cls.
|
Names subclass
results in all of the constants it contains.| Returns | an iterator the elements of which are the NamedConstant
instances defined in the body of this Names subclass.
| |