[Tutor] Class access rules

Mats Wichmann mats at wichmann.us
Sun Mar 6 19:42:53 EST 2022


On 3/6/22 17:33, Phil wrote:
> I've imported the following class into several wxpython projects and now
> into a tkinter project and now I'm wondering if I should modify the
> class by adding setter and getter methods instead of directly accessing
> the instance attributes. 

Why?

It's not Java, so it's fine to leave them as attribute access. If you
later find you need to add some extra stuff, you can create a getter
and/or setter that retains the same apparent attribute access method.

If you have a real reason why they need to be getters/setters, then of
course go ahead.




More information about the Tutor mailing list