When creating #python library code, how do you feel about __init__.py files that import all the public names, so that client code imports them from one place?

Reasons for your answer are welcome. Notes on this issue from the perspective of a library user are welcome too.

Follow

@pbx I missed the poll, but I think it's really an "it depends" situation.

When there is a mismatch between the best way to structure your package from a maintenance perspective and the best namespace structure from a user's perspective, you should use imports to expose symbols to the public in the best way regardless of their internal organization.

In packages with a relatively small public interface with a lot of structure or complexity behind it, collapsing the public interface into one namespace makes a lot of sense.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.