Created
February 27, 2020 13:54
-
-
Save koi8-r/4105316400b9948ca4501ea6d86c170d 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 Product(object): | |
url: str | |
def __getattribute__(self, name): | |
ret = object.__getattribute__(self, name) | |
if isinstance(ret, property): | |
return ret.__get__(self) | |
return ret | |
val = None | |
class LazyVal(object): | |
def get(self): | |
return getattr(self, '__val') | |
def set(self, val): | |
setattr(self, '__val', val) | |
def lazy_getter(self): | |
return val | |
def Lazy(): | |
return property(lazy_getter) | |
product = Product() | |
product.url = Lazy() # Lazy(val) | |
print(product.url) | |
val = 9 | |
print(product.url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment