Guest User

Untitled

a guest
Dec 16th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # Property "x" is a descriptor becacuse it has __get__, __set__ and __delete__
  2. x = property() # simple property
  3. print(x.__get__) # -> <method-wrapper '__get__' of property object at 0x7fbe86fda188>
  4. print(x.__set__) # -> <method-wrapper '__set__' of property object at 0x7fbe86fda188>
  5. print(x.__delete__) # -> <method-wrapper '__delete__' of property object at 0x7fbe86fda188>
  6.  
  7. # Lets see that __get__ actually calls (wraps) fget
  8. lst = [1,2] # using lst to prove with is that we getting the same object
  9. x = property(fget = lambda self: lst)
  10. print(x.__get__('dummy_self') is lst) # -> True, proving __get__ wraps fget
Add Comment
Please, Sign In to add comment