What's the python __all__ module level variable for?
namespaces, python
Solution
It has two purposes:
Anybody who reads the source will know what the exposed public API is. It doesn't prevent them from poking around in private declarations, but does provide a good warning not to.
When using `from mod import *`, only names listed in `__all__` will be imported. This is not as important, in my opinion, because importing everything is a really bad idea.
Problem
I've seen it a lot in python/Lib source code but I don't know what it is for. I thought it was used to limit accessible members of of a module. So only the elements at `__all__` will show up when `dir(module)`. I did a little example and saw it was not working as I expected. So... What's the python `__all__` module level variable for?