Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created October 21, 2009 13:11
Show Gist options
  • Save yaotti/215094 to your computer and use it in GitHub Desktop.
Save yaotti/215094 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from time import sleep
def do_heavy_process():
sleep(3)
return 10
class myclass():
def __init__(self):
self.__val = None
@property
def val(self):
self.__val = self.__val or do_heavy_process()
return self.__val
obj = myclass()
print obj.val
print obj.val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment