-
Notifications
You must be signed in to change notification settings - Fork 4
singleton
Woong Gyu La edited this page Sep 27, 2016
·
6 revisions
pyserver
also has a singleton
container. When creating singleton
class, it can be simply done by adding an annotation:
from pyserver.util import *
...
@Singleton
class TempSingletonClass(object):
def __init__(self):
self.text = 'Hello World'
def touch(self):
print self.text
...
TempSingletonClass.instance().touch() # 'Hello World'
* Note that the Singleton class must not have any mandatory argument for the contructor!