Skip to content

Instantly share code, notes, and snippets.

@Pycz
Created June 25, 2014 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pycz/2a3c19f393b115d6f56c to your computer and use it in GitHub Desktop.
Save Pycz/2a3c19f393b115d6f56c to your computer and use it in GitHub Desktop.
class Monk(object):
monk = None
def __call__(self):
if not self.monk:
self.monk = Monk()
return self.monk
a = Monk()
print a
print a
print a
print a()
print a()
print a()
print a()()
print a()()
print a()()
print a()()()
print a()()()
print a()()()
<__main__.Monk object at 0xb74be16c>
<__main__.Monk object at 0xb74be16c>
<__main__.Monk object at 0xb74be16c>
<__main__.Monk object at 0xb74be1ac>
<__main__.Monk object at 0xb74be1ac>
<__main__.Monk object at 0xb74be1ac>
<__main__.Monk object at 0xb74be1cc>
<__main__.Monk object at 0xb74be1cc>
<__main__.Monk object at 0xb74be1cc>
<__main__.Monk object at 0xb74be1ec>
<__main__.Monk object at 0xb74be1ec>
<__main__.Monk object at 0xb74be1ec>
[Finished in 0.0s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment