I am from the C# background.
I am trying to write getter and setters methods. In other words, I am trying to create properties for a class.
class ParamDefinition:
def __init__(self, type_name):
self.__type_name = type_name
@property
def get_type_name(self):
return self.__type_name
@get_type_name.setter
def set_type_name(self, type_name):
self.__type_name = type_name
def printf(self):
print(self.__type_name)
def test():
compDef = ParamDefinition(None)
compDef.type_name = "int"
compDef.printf()
if __name__ == "__main__":
test()
Output:
None
What is incorrect with my property-definition?