DEV Community

Discussion on: Python setter and getter function

Collapse
 
fronkan profile image
Fredrik Sjöstrand

I also agree with these comments. Furthermore, this will completely break all help a good ide or text editor will give you, like suggestions and auto-completion. I have never seen this style of coding before. You usually define all fields of a class inside the dunder init method of the class.

class MyClass:
    def __init__(self, name):
        self.name = name
me = MyClass("Fredrik")
print(me.name) #Fredrik