A couple of interesting capabilities in this post. The section "Controlling What Can Be Imported and What Not" is wrong or misleading though. The dunder __all__ only limits wildcard imports like `from my_module import * `. In your example both `foo` and `bar` can be imported/accessed like `from my_module import foo, bar` or `import my_module; my_module.foo(); my_module.bar()`.
Edit: Also just tried to `import * ` with `_all__ = []` and no AttributeError is raised as is stated. Python 3.7.4
Edit: Also just tried to `import * ` with `_all__ = []` and no AttributeError is raised as is stated. Python 3.7.4