Module Gnumed.pycommon.gmBorg
A base class turning child classes into a Singleton.
Classes
class cBorg (*args, **kargs)
-
Expand source code
class cBorg: """A generic Borg mixin for new-style classes. - mixin this class with your class' ancestors to borg it - there may be many _instances_ of this - PER CHILD CLASS - but they all share _state_ """ _instances:dict = {} def __new__(cls, *args, **kargs): # look up subclass instance cache if cBorg._instances.get(cls) is None: #cBorg._instances[cls] = object.__new__(cls, *args, **kargs) cBorg._instances[cls] = object.__new__(cls) return cBorg._instances[cls]
A generic Borg mixin for new-style classes.
-
mixin this class with your class' ancestors to borg it
-
there may be many instances of this - PER CHILD CLASS - but they all share state
Subclasses
-