import math
class Circulo( ) :
def __init__ ( self ) :
super ( )
self .__raio = None
def get_perimetro( self ) :
return 2 * math .pi * self .raio
def get_area( self ) :
return math .pi * self .raio ** 2
@ property
def raio( self ) :
return self .__raio
@ raio.setter
def raio( self , x) :
self .__raio = x
def __setattr__ ( self , key, value) :
if not hasattr ( self , key) :
raise TypeError ( "Não pode criar atributos para esta classe" )
object .__setattr__ ( self , key, value)
c = Circulo( )
c.raio = 2 # ok
c.lado = 2 # AttributeError
#https://pt.stackoverflow.com/q/220908/101
aW1wb3J0IG1hdGgKIApjbGFzcyBDaXJjdWxvKCk6CiAgICBkZWYgX19pbml0X18oc2VsZik6CiAgICAgICAgc3VwZXIoKQogICAgICAgIHNlbGYuX19yYWlvID0gTm9uZQogCiAgICBkZWYgZ2V0X3BlcmltZXRybyhzZWxmKToKICAgICAgICByZXR1cm4gMiAqIG1hdGgucGkgKiBzZWxmLnJhaW8KIAogICAgZGVmIGdldF9hcmVhKHNlbGYpOgogICAgICAgIHJldHVybiBtYXRoLnBpICogc2VsZi5yYWlvICoqIDIKIAogICAgQHByb3BlcnR5CiAgICBkZWYgcmFpbyhzZWxmKToKICAgICAgICByZXR1cm4gc2VsZi5fX3JhaW8KIAogICAgQHJhaW8uc2V0dGVyCiAgICBkZWYgcmFpbyhzZWxmLCB4KToKICAgICAgICBzZWxmLl9fcmFpbyA9IHgKIAogICAgZGVmIF9fc2V0YXR0cl9fKHNlbGYsIGtleSwgdmFsdWUpOgogICAgICAgIGlmIG5vdCBoYXNhdHRyKHNlbGYsIGtleSk6CiAgICAgICAgICAgIHJhaXNlIFR5cGVFcnJvcigiTsOjbyBwb2RlIGNyaWFyIGF0cmlidXRvcyBwYXJhIGVzdGEgY2xhc3NlIikKICAgICAgICBvYmplY3QuX19zZXRhdHRyX18oc2VsZiwga2V5LCB2YWx1ZSkKIApjID0gQ2lyY3VsbygpCmMucmFpbyA9IDIgIyBvawpjLmxhZG8gPSAyICMgQXR0cmlidXRlRXJyb3IKCiNodHRwczovL3B0LnN0YWNrb3ZlcmZsb3cuY29tL3EvMjIwOTA4LzEwMQ==