def singleton(theClass):
    """ decorator for a class to make a singleton out of it """
    classInstances = {}

    def getInstance():
        """ creating or just return the one and only class instance """
        if theClass not in classInstances:
            classInstances[theClass] = theClass()
        return classInstances[theClass]

    return getInstance
 decorator for a class to make a singleton out of it 
recipes/Python/578015_Simple_enum_mechanism/recipe-578015.py