Explain, please what
__ all __ (I understand that this is a certain list), in what cases is it used in Python and how is it applied when importing?
I read bizli, but there is somehow it is written and the example is incomprehensible, I did not understand, honestly. The googling also did not particularly help …
Answer 1, Authority 100%
__ All __ In Pythone, this is a list of public objects of this module. Those, let’s say, you have some myModule.py, it describes a lot of objects, and it is not necessary to use them by everyone. In
__ ALL __ in mymodule.py, you define the names of objects that can be imported (
__ All__ = ["MyClass", "MyClass2"] ).
Those., For example, from from MyModule Import * only those objects that you described in
__ ALL __ are imported.
__ all __ directive will correctly call one of the levels of encapsulation in Python.