I am creating a python class out of raw data as follows:
Class Test:
def __init__(self, raw_number):
self._raw_number = raw_number
I am then computing _raw_number
as a property to return the actual number I would like to have:
@property
def number(self):
return self._raw_number[0]
However, when trying to set this property on a Test
object using
t = Test([1, 2, 3]) # this will set the number property to 1
t.number = 5 # this is supposed to set the number property to 5
I am running into an error that says property number cannot be set
.
I am wondering why I can solve this?