PEP 842: Module Exports

It can be discouraged, not prevented. See this section. In short, the easiest way to do this is to access __dict__:

import module

module.__dict__['private']

I agree that internals are nice to have when you need them, which is why I’m not proposing some ironclad shield around private variables. The documentation/introspection aspect, as Barry said, is the more interesting part, and the attribute access enforcement is mostly a formality.

4 Likes