Created
October 21, 2009 13:11
-
-
Save yaotti/215094 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 | |
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