DEV Community

Discussion on: Python/Django Developer Interview Questions and Answer (#1)

Collapse
 
lhaze profile image
Łukasz Haze

"Name mangling" (so called) was't meant to be confused with the concept of "privacy". It's a common misconception. It's in the language to help to mitigate the problem of class field name collisions while the inheritance comes into the game. Think of the __slots__ class attribute or any API-like class mechanics using both inheritance and class fields (Django models). You may want to have each subclass add its value to the mechanics, not to override superclasses' values.