Created
February 21, 2011 09:29
-
-
Save tanelpuhu/836853 to your computer and use it in GitHub Desktop.
This file contains 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
class Singleton: | |
__single = None | |
def __init__( self ): | |
if Singleton.__single: | |
raise Singleton.__single | |
Singleton.__single = self | |
def Handle(x = Singleton): | |
try: | |
single = x() | |
except Singleton, s: | |
single = s | |
return single | |
assert(Handle() == Handle()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment