Add the export keyword to Python

In my opinion, the problems with the current system are that:

  • producing an interface means specifying redundant information in
    • module __all__s,
    • __init__.py’s __all__, and
    • __init__.py’s import statements.
  • keeping the interface concise requires either
    • deleting unwanted symbols, or
    • having a clean parallel directory structure of modules (as described above).
  • also, keeping the interface concise means
    • being conscious that from .abc import def will create the symbol abc as well as def.

It’s a hard problem to solve since there are essentially two consumers: endogenous imports wherein the library itself wants to import its own symbols (from ..xyz import symbol) and exogenous imports (from some_library import symbol).

Currently, the external interface is specified by __init__.py’s __all__. In an ideal world, only those symbols would be available to exogenous imports. My suggestion is that we come with simple ways of ensuring this. By simple, I mean having none of the above issues (redundant information, using del, having a parallel structure, worrying about relative imports polluting the interface).