class Singleton:
    class __impl:
        """ Implementation of the singleton interface """

        def spam(self):
            """ Test method, return singleton id """
            return id(self)

    # storage for the instance reference
    __instance = None

    def __init__(self):
        """ Create singleton instance """
        # Check whether we already have an instance
        if Singleton.__instance is None:
            # Create and remember instance
            Singleton.__instance = Singleton.__impl()

        # Store instance reference as the only member in the handle
        self.__dict__['_Singleton__instance'] = Singleton.__instance

    def __getattr__(self, attr):
        """ Delegate access to implementation """
        return getattr(self.__instance, attr)

    def __setattr__(self, attr, value):
        """ Delegate access to implementation """
        return setattr(self.__instance, attr, value)
    
class ValueHandler(Singleton):
    def __init__(self):
        Singleton.__init__(Singleton())
        self.__values = {}
    
    def __setitem__(self,item,value):
        self.__values[item] = value
        
    def __getitem__(self,item):
        return self.__values[item]
    
    def update(self,**dic):
        self.__values.update(dic)
    
    def keys(self):
        return list(self.__values.keys())
