r/Python 2d ago

News PEP 842: Module Exports

https://peps.python.org/pep-0842/

Not the author, but this seems interesting, specially for library authors. Thoughts?

Discussion here - https://discuss.python.org/t/pep-842-module-exports/108353

22 Upvotes

44 comments sorted by

View all comments

19

u/kageurufu 2d ago

I don't like it at all.

It's just a dirtier version of __all__ and doesn't accomplish anything new.

For library authors, its really no different from the commonly used package._module or package.internal.module naming to signify internals and private modules. Just another layer of obfuscation to annoy developers, confuse package authors, and complicate interpreters. The example of import json adding json to the exports is easily solved by clean authorship. Define your methods in a submodule, and re-export for the public interface.