fix(curriculum): ensure setters run during object initialization (#65113)

This commit is contained in:
Lakshay Goyal
2026-01-16 00:37:04 +05:30
committed by GitHub
parent bdb6c39fc9
commit f5364864ee
@@ -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 `@<property_name>.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