I know that getters and setters are important in java as you usually have private attributes, but I cannot find any use in making them in Python.
If we take for exemple the User class given below:
class User: def __init__(self, username): self.logined = True self.username = username def logout(self): self.logined = False self.username = None def login(self, username): self.logined = True self.username = username def is_logined(self): return self.logined
And then creating an instance of User in a main.py
user = User("Pixa253lulu")user.logout()#Way 1print(user.is_logined())#Way 2print(user.logined)
Both would return True in that case, and seems to work just fine in any situation.So is there any practical use like in Java, or is using those just commiting to OOP?