From f5364864ee11db706c3f3f1b1dd2e14225f9e524 Mon Sep 17 00:00:00 2001 From: Lakshay Goyal Date: Fri, 16 Jan 2026 00:37:04 +0530 Subject: [PATCH] fix(curriculum): ensure setters run during object initialization (#65113) --- .../68c128cbd77e4ba9ed671937.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/curriculum/challenges/english/blocks/lecture-understanding-object-oriented-programming-and-encapsulation/68c128cbd77e4ba9ed671937.md b/curriculum/challenges/english/blocks/lecture-understanding-object-oriented-programming-and-encapsulation/68c128cbd77e4ba9ed671937.md index 43f2596a5fb..f6b216d949b 100644 --- a/curriculum/challenges/english/blocks/lecture-understanding-object-oriented-programming-and-encapsulation/68c128cbd77e4ba9ed671937.md +++ b/curriculum/challenges/english/blocks/lecture-understanding-object-oriented-programming-and-encapsulation/68c128cbd77e4ba9ed671937.md @@ -50,10 +50,12 @@ Notice how we used `_radius` instead of radius inside the class. The underscore To make a setter to create the radius, for example, you have to define another method with the same name and use `@.setter` above it: +Using `self.radius` inside `__init__` ensures the setter runs during object creation, so invalid radius values are caught immediately. + ```py class Circle: def __init__(self, radius): - self._radius = radius + self.radius = radius # Calling the setter @property def radius(self): # A getter to get the radius @@ -90,7 +92,7 @@ A deleter runs custom logic when you use the del statement on a property. To cre ```py class Circle: def __init__(self, radius): - self._radius = radius + self.radius = radius # Getter @property