2
I would like to know how I can simulate a read-only property on Python
.
For example, I have the following code:
class IPInfo(object):
def __init__(self, ip):
self.ip = ip;
ip = IPInfo(object)
ip.ip = 'aqui é possível editar, mas quero desabilitar isso';
print ip.ip #aqui é possível imprimir, pois a leitura é permitida
How could I make the property ip
read-only?
I do not think so, I say this supported here: http://stackoverflow.com/questions/2682745/how-to-create-a-constant-in-python
– Miguel
@Miguel gives yes :p.
– Wallace Maxters
Ok, if it is with decorators gives
– Miguel
That’s right, hehehehe
– Wallace Maxters