Top-rated recipes tagged "export"http://code.activestate.com/recipes/tags/export/top/2012-09-19T19:13:20-07:00ActiveState Code RecipesUsing doctests to verify a module's export list (Python)
2012-09-19T19:13:20-07:00Sam Dentonhttp://code.activestate.com/recipes/users/4172262/http://code.activestate.com/recipes/578266-using-doctests-to-verify-a-modules-export-list/
<p style="color: grey">
Python
recipe 578266
by <a href="/recipes/users/4172262/">Sam Denton</a>
(<a href="/recipes/tags/doctest/">doctest</a>, <a href="/recipes/tags/export/">export</a>, <a href="/recipes/tags/module/">module</a>, <a href="/recipes/tags/python/">python</a>).
Revision 2.
</p>
<p>If you aren't very careful, modules can end up exporting more symbols than you intend. For example, everything that you import is added to your module's name-space. Then there's scaffolding and other stuff intended for internal use. The usual advice is to name everything with a leading underscore, but that gets complicated fast: "import sys as _sys", "from os import environ as _environ". The alternative is to use "__all__ " to define exactly what you want to export, but then you need to maintain it as you add things to your module. <em>Or do you?</em></p>