plainbox.impl.symbol – Symbol Type

Symbols are special values that evaluate back to themselves. They are global, unlike enumeration values, and are not bound to any container that defined them. Symbols can be easily converted to strings and back and are a useful way to store constants for use inside applications or libraries.

Applications can use Symbol class directly or use the SymbolDef helper to quickly construct symbols without syntax overhead.

class plainbox.impl.symbol.Symbol(name)[source]

Bases: object

Symbol type.

Instances of this class behave as self-interning strings. All instances are tracked and at most one instance with a given symbol name can be constructed. The name is immutable.


name of the symbol

class plainbox.impl.symbol.SymbolDef[source]

Bases: object

Helper class that allows to easily define symbols.

All sub-classes of SymbolDef are evaluated specially. Each word used inside the class definition becomes a Symbol() instance. In addition explicit assignment can create new symbols. This can be used to create symbols with value different from their identifiers.

classmethod get_all_symbols()

Get all symbols defined by this symbol definition block

comments powered by Disqus