A Module's Public Import Surface

A module's public surface consists of names and behavior other modules are expected to import and rely on.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Choose a stable import path
  2. Avoid import-time work surprises

Choose a stable import path

Expose a report-writing function at a predictable path. Its implementation can move to another internal module while that path continues to export it. Public and private helpers describes a function-level version of this boundary.

Avoid import-time work surprises

A consumer importing the public function may want to unit test it without generating a report. Keep execution behind a documented entry point when import should only make definitions available.[1]

References

  1. Python Software Foundation, Python Tutorial: Classes ↩