Inconsistent behaviour when importing my own module in Python 2.7
<p>I have created a module, it's sitting in its own folder with an <code>__init__.py</code> and four files that contain my classes.</p>

<p>When doing <code>from MyPackage import *</code> I'm getting the modules that I have written into the <code>__all__</code> statement in my <code>__init__.py</code> just as expected.</p>

<p>When doing <code>from MyPackage import ModuleX</code> I can import any module individually just fine.</p>

<p>When doing <code>import MyPackage</code> and then say <code>dir(MyPackage)</code> however, all I get is this:</p>

<pre><code>['__all__',
 '__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__']
</code></pre>

<p>My modules aren't shown and I can't access them using <code>MyPackage.ModuleX</code> either.</p>

<p>The only thing I have written into my <code>__init__.py</code> is the <code>__all__ = [ModuleX]</code> statement.</p>

<p>Why does the last statement not see my modules? Do I have to set some more configuration?</p>

<p><code>__all__</code> determines what names are <em>exported</em> from that module. However in order to export them you would need to import them in the first place, which you haven't.</p>

python python-2.7 module