Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Property "x" is a descriptor becacuse it has __get__, __set__ and __delete__
- x = property() # simple property
- print(x.__get__) # -> <method-wrapper '__get__' of property object at 0x7fbe86fda188>
- print(x.__set__) # -> <method-wrapper '__set__' of property object at 0x7fbe86fda188>
- print(x.__delete__) # -> <method-wrapper '__delete__' of property object at 0x7fbe86fda188>
- # Lets see that __get__ actually calls (wraps) fget
- lst = [1,2] # using lst to prove with is that we getting the same object
- x = property(fget = lambda self: lst)
- print(x.__get__('dummy_self') is lst) # -> True, proving __get__ wraps fget
Add Comment
Please, Sign In to add comment