Created
November 24, 2010 22:34
-
-
Save adh/714556 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
>>> def singleton(klass): | |
... inst = klass() | |
... return lambda:inst | |
... | |
>>> @singleton | |
... class Bar: | |
... pass | |
... | |
>>> Bar() | |
<__main__.Bar instance at 0x7fea76c054d0> | |
>>> Bar() | |
<__main__.Bar instance at 0x7fea76c054d0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment