-
-
Save maksymx/dab9868edaf93849feee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class Hello(object): | |
singleton = None | |
def __new__(clz): | |
if not clz.singleton: | |
clz.singleton = object.__new__(clz) | |
return clz.singleton | |
def __init__(self): | |
self.world = "world" | |
return None | |
h = Hello() | |
h.hello = "hello" | |
print h.hello | |
print h | |
print h.world | |
x = Hello() | |
print x.hello | |
print x | |
print x.world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment