Exercise: Add a Property With Validation
Bartosz Zaczyński RP Team on May 24, 2026
@AndersC Good question, and you’ve spotted a subtle but important distinction.
When you write self.celsius = value, Python looks up celsius on the class, finds the property, and runs the setter, which includes your validation. When you write self._celsius = value, you’re just setting a regular attribute directly, so the setter never runs and the validation is skipped. That’s why Temperature(-300) doesn’t raise ValueError in that case.
About the Circle example: notice that Chris assigns to self._radius inside the setter itself, not in .__init__(). He has to, because assigning to self.radius inside its own setter would call the setter again, causing infinite recursion. That’s the one place you must use the underscore name. Everywhere else (including .__init__()), you go through the property so the validation runs.
Miguel_T on May 29, 2026
With self._radius = radius in the .__init__() as it is in the video, the validation is skipped when first creating an object for the reason Bartosz Zaczyński pointed out. You can test with Circle(-1). Shouldn’t the video match the solution of the exercise?
Become a Member to join the conversation.

AndersC on May 23, 2026
In the
.__init__()method, I had to writeself.celsius = valuefor the test to pass. If I writeself._celsius = value, I get an error message saying:Why? In the lecture, it uses the non public attribute
self._radiusin the circle example.