<p>The gurus will have to correct me if this is not an accepted practice, but I know some projects (Fabric is the one that comes to mind) will define a submodule specifically for the 'from blah import *' situation. The submodule would be called "api", or something like that, so you can do: 'from mymodule.api import *' to separate the items you want to include in your public api, while still keeping other names importable by 'import blah'</p>

<div class="gmail_quote">On Aug 9, 2011 1:00 PM, "Steven D&apos;Aprano" <<a href="mailto:steve%2Bcomp.lang.python@pearwood.info">steve+comp.lang.python@pearwood.info</a>> wrote:<br type="attribution">
> Ethan Furman wrote:<br>> <br>>> Greetings!<br>>> <br>>> Does anyone know/recall the original purpose of __all__?<br>> <br>> To customise the names available for `from ... import *`:<br>> <br>
> <a href="http://docs.python.org/whatsnew/2.1.html#other-changes-and-fixes">http://docs.python.org/whatsnew/2.1.html#other-changes-and-fixes</a><br>> <br>> <br>>> I had thought it was primarily to specify what would be imported when<br>
>> `from ... import *` was executed, such as for tk;  <br>> <br>> Yes, that was the original use. If __all__ is not defined, Python will<br>> import everything that doesn't start with an underscore.<br>
> <br>> <br>>> today, it seems it is <br>>> also used to specify the API for the module, and so the help() subsystem<br>>> will only provide details for those items found in __all__.<br>> <br>> The two meanings are assumed to be synonymous: names in the public API<br>
> should be importable with *, and importable names should be in the public<br>> API. You can't specify "this can be imported with *, but isn't public"<br>> or "this is public, but not importable with *".<br>
> <br>> <a href="http://docs.python.org/reference/simple_stmts.html#index-1090">http://docs.python.org/reference/simple_stmts.html#index-1090</a><br>> <br>> <br>> Also, the behaviour of __all__ with packages may be slightly different:<br>
> <br>> <a href="http://docs.python.org/tutorial/modules.html#index-1134">http://docs.python.org/tutorial/modules.html#index-1134</a><br>> <br>>  <br>>> The issue I'm having with this is that there are roughly a dozen items I<br>
>> would like to make available via the `import *` mechanism in my dbf<br>>> module, and another dozen that, while part of the public API, don't need<br>>> to be available via an `import *`.<br>> <br>
> You have to choose both, or neither, but you can't have just one.<br>> <br>> <br>> <br>> -- <br>> Steven<br>> <br>> -- <br>> <a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div>