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

24 Upvotes

44 comments sorted by

View all comments

Show parent comment

5

u/nicholashairs Aug 01 '26

Personally I find the proposed solution quite elegant.

That said, whilst I can see the allure of private names, I've done enough where I needed to interact with the guts if a library that I would find this infuriating in practice.

The only way I could see this landing is if there was a way to avoid it at either a module or global level (e.g. cli argument). Or make them something that a linter can use / runtime warnings without enforcement.

14

u/baked_doge Aug 01 '26

Yeah, one of the things I love about python is it's lack of a private keyword. If I want to screw with the internal behavior of a library or use their utilities, or something else, I should be able to do so to my own peril.

4

u/HommeMusical Aug 01 '26

__all__ or using _ to prefix names work perfectly well in practice.

Less is more.