Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/util/Singleton.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/Singleton.py')
-rw-r--r--util/Singleton.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/util/Singleton.py b/util/Singleton.py
new file mode 100644
index 0000000..c161866
--- /dev/null
+++ b/util/Singleton.py
@@ -0,0 +1,16 @@
+class Singleton(object):
+ _instance = None
+ def __new__(cls, * args, ** kwargs):
+ if not cls._instance:
+ cls._instance = super(Singleton, cls).__new__(
+ cls, * args, ** kwargs)
+ return cls._instance
+
+
+if __name__ == '__main__':
+ s1 = Singleton()
+ s2 = Singleton()
+ if s1 == s2:
+ print "Same"
+ else:
+ print "Different" \ No newline at end of file