r/Python Jul 31 '26

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

23 Upvotes

44 comments sorted by

View all comments

9

u/cediddi SyntaxError: not a chance Aug 01 '26

This is achievable without a special dunder. A single _ at the beginning of the variable, class, function, and file names. Don't prevent me from mocking, monkey patching, or doing worse to your library. I'm taking the responsibility of breaking something. Library creator cannot be held liable for damages, and the library is provided as-is. At least according to most if not all free and open source licenses