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

-1

u/Schmittfried Aug 01 '26

I agree, but a string list of names goes out of sync super fast. I think a more elegant solution would be a way to import modules without transitively exporting them.

import hidden numpy  # not visible to packages importing this one

1

u/denehoffman Aug 01 '26

I think new syntax is definitely not the way to go here. The @public decorator would be cool to have with some enforcement.

1

u/Schmittfried Aug 01 '26

As long as it’s not a string list, it’s opt-in and backwards-compatible I’m all for it.