News for hackers. Stuff that matters.
Re:Object Oriented Programming in Python: Encapsulation and ... by orf on Sunday September 24, 2017 @01:22PM (#15325579)
Sure that was the idea, but I don't think I have ever seen any code use it like this.

A single underscore is something that's not part of the classes public API, any child classes may need to change attributes, and by using a double underscore you are saying "I know better than you, you won't ever need to change this", which is never true.

Python isn't like Java where you often have complex and often convoluted class heirachies, where truly private attributes might be more useful.

There are no comments on this comment yet.