def singleton(cls):
 instances = {}
 def getinstance():
  if (cls not in instances):
   instances[cls] = cls()
  return instances[cls]
 return getinstance

def singleton ( cls ) : instances = { } def getinstance ( ) : if ( cls not in instances ) : instances [ cls ] = cls ( ) return instances [ cls ] return getinstance
simple wrapper for classes that should only have a single instance .