2.5 Who can access my data?
Object-oriented programming languages have a concept of access control. This is related to the concept of encapsulation. Some languages have a spectrum of access controls including private, protected, public, and final.
Python doesn’t do this. Instead, Python is kept very simple, and provides some guidelines and best practices. All methods and attributes on a class are publicly available. We often remind each other of this by saying “We’re all adults here.” There’s no need to declare a variable as private or protected when we can all see the source code.
If we want to suggest that a method should not be used publicly, we really need to put a note in docstrings indicating that the method is meant for internal use only. Ideally, we include an explanation of how the public-facing API works. We often supplement this with examples copied and pasted from REPL interaction; examples that can be tested by the...