class symbol(object):
A constant symbol.
>>> symbol('foo') is symbol('foo') True >>> symbol('foo') <symbol 'foo>
A slight refinement of the MAGICCOOKIE=object() pattern. The primary advantage of symbol() is its repr(). They are also singletons.
Repeated calls of symbol('name') will all return the same instance.
The optional doc argument assigns to __doc__. This is strictly so that Sphinx autoattr picks up the docstring we want (it doesn't appear to pick up the in-module docstring if the datamember is in a different module - autoattribute also blows up completely). If Sphinx fixes/improves this then we would no longer need doc here.
Class Method | parse_user_argument |
Given a user parameter, parse the parameter into a chosen symbol. |
Method | __new__ |
Undocumented |
Class Variable | _lock |
Undocumented |
Class Variable | symbols |
Undocumented |
Given a user parameter, parse the parameter into a chosen symbol.
The user argument can be a string name that matches the name of a symbol, or the symbol object itself, or any number of alternate choices such as True/False/ None etc.
Parameters | |
arg | the user argument. |
choices | dictionary of symbol object to list of possible entries. |
name | name of the argument. Used in an .ArgumentError
that is raised if the parameter doesn't match any available argument. |
resolve_symbol_names | include the name of each symbol as a valid entry. |