Python Encapsulation - LinuxConfig.org

Encapsulation is one of the fundamental aspects of Object Oriented Programming. It allows programmers better control of how data flows in their programs, and it protects that data. Encapsulation also makes objects into more self-sufficient and independently functioning pieces.
This is a companion discussion topic for the original entry at https://linuxconfig.org/python-encapsulation

Seventy Five

Actually, protected is much more useful than private in the industry,
and while not my entire experience was in OOP, the last 18 years were, and from hard RT to soft comms, that is what I’ve seen.

You may hear “protected by convention”, but that’s an extremely naive
approach, as devs would immediately break that convention to solve an
urgent bug, but would be VERY hesitant to explicitly change access, I’ve
actually seen the first more times than I remember, but don’t really
need an entire hand to count the times I’ve seen the latter.

The only reason that this is not a design flaw in Python, is that Python was
intended as a smart scripting language originally, but now that people
start using it for big projects, it’s getting harmful.