Dec-30-2021, 03:41 PM
Hey,
I have a simple class like this:
I have a simple class like this:
class Test:
def __init__(self, name):
self._name = name
@property
def name(self):
return self._name
@name.setter
def name(self, n_val):
self._name = str(n_val).capitalize()I was expecting it to invoke the setter during creation, so the following would return a capitalized name: test_cl = Test("jimmy")
print(test_cl.name)But the output is still:Output:jimmyShouldn't the init run the setter and if not, is it possible to have it do so?
