Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. '''
  2. Teste de Gets
  3. '''
  4.  
  5.  
  6. class Cor():
  7. '''
  8. Uma Cor Qualquer
  9. '''
  10. def __get__(self, pai, outro):
  11. return pai.cor
  12.  
  13.  
  14. class Cabelo():
  15. '''
  16. Um cabelo qualquer
  17. '''
  18. coloracao = Cor()
  19.  
  20. def __init__(self, cor, tipo):
  21. self.cor = cor
  22. self.tipo = tipo
  23.  
  24. def __get__(self, atributo, outro):
  25. return getattr(self, atributo)
  26.  
  27. def __int__(self):
  28. return len(self.cor)
  29.  
  30.  
  31. if __name__ == "__main__":
  32. X = Cabelo("escuro", "cacheado")
  33.  
  34. print(X.coloracao)
  35. print(X.tipo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement