Python doesn't have any mechanism that effectively restricts access to any instance variable or method. Python prescribes a convention of prefixing the name of the variable/method with single or double underscore to emulate the behaviour of protected and private access specifiers.
class Employee(object):
def __init__(self, name, sal):
self._name=name # protected attribute
self._salary=sal # protected attribute
while this mechanism is used in Object Oriented programming , my question is can we use this approach to convey other developers that how I want the access of a variable or an imported module in my python module.
In a company I worked long back we had a practice to use _ with a variable or an import if we want to tell the developers that I do not want this variable or module I imported here to be access from outside this module.
if it is the way to tell how I want to define the access of variable or a module or function or class I import from elsewhere into my module. Is it documented somewhere ? (like in ieee.org)
**some_module.py**
from some_module_api import preset as _preset
.
.
.