View of /PEAK/src/peak/util/symbols.py
Parent Directory
| Revision Log
Revision:
1530 -
(
download)
(
as text)
Fri Dec 5 16:46:15 2003 UTC (20 years, 4 months ago) by
pje
File size: 765 byte(s)
Whoops, forgot to 'cvs add' peak.util.symbols. All the tests passed, but
only on my machine. Thanks for the heads-up, Ulrich.
"""Symbolic global constants, like 'None', 'NOT_FOUND', etc."""
__all__ = [
'Symbol','NOT_GIVEN','NOT_FOUND'
]
class Symbol(object):
"""Symbolic global constant"""
__slots__ = ['_name', '_module']
__name__ = property(lambda s: s._name)
__module__ = property(lambda s: s._module)
def __init__(self, symbol, moduleName):
self.__class__._name.__set__(self,symbol)
self.__class__._module.__set__(self,moduleName)
def __reduce__(self):
return self._name
def __setattr__(self,attr,val):
raise TypeError("Symbols are immutable")
def __repr__(self):
return self.__name__
__str__ = __repr__
NOT_GIVEN = Symbol("NOT_GIVEN", __name__)
NOT_FOUND = Symbol("NOT_FOUND", __name__)