Next / Previous / Contents / Shipman's homepage

46.2. class Singleton
# - - - - -   c l a s s   S i n g l e t o n

class Singleton(object):
    '''Base class for singleton objects.

          [ a dictionary whose keys are the classes
            instantiated so far, and each related value
            is the single instance of that class ]

This class can manage any number of different derived classes. A class variable, .__classMap, is used to keep track of their instances.
    __classMap = {}