The quoted statement is incorrect. The __height
field is indeed defined in the constructor __init__()
, where it is initialized with the value of the parameter h
. The @property
decorator does not define the field; instead, it provides a way to access the private attribute __height
through a public interface. The @height.setter
decorator allows you to set the value of __height
while enforcing any conditions specified in the setter method.
In summary, the correct understanding is that the __height
field is explicitly defined in the constructor, and the decorators are used to manage access to this private field.
References: