Advertisement
mauricioribeiro

Classe Universo - Brincando com magic methods

Sep 29th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. class Universo(str):
  2.     def __gt__(self, other): return 'Um universo nunca será maior que o outro...' if type(other) == type(self) else True
  3.     def __lt__(self, other): return 'Um universo nunca será menor que o outro...' if type(other) == type(self) else False
  4.     def __eq__(self, other): return True
  5.     def __ne__(self, other): return False
  6.  
  7. universo_a = Universo()
  8. universo_b = Universo()
  9.  
  10. print(universo_b > universo_a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement