fork(1) download
  1. import math
  2.  
  3. class Circulo():
  4.  
  5. __slots__ = ("__raio")
  6.  
  7. def __init__(self):
  8. super()
  9. self.__raio = None
  10.  
  11. def get_perimetro(self):
  12. return 2 * math.pi * self.raio
  13.  
  14. def get_area(self):
  15. return math.pi * self.raio ** 2
  16.  
  17. @property
  18. def raio(self):
  19. return self.__raio
  20.  
  21. @raio.setter
  22. def raio(self, x):
  23. self.__raio = x
  24.  
  25. c = Circulo()
  26. c.raio = 2 # ok
  27. c.lado = 2 # AttributeError
Runtime error #stdin #stdout #stderr 0.02s 28384KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 27, in <module>
AttributeError: 'Circulo' object has no attribute 'lado'