Python packages - import by class, not file
<p>Say I have the following file structure:</p>

<pre><code>app/
  app.py
  controllers/
    __init__.py
    project.py
    plugin.py
</code></pre>

<p>If app/controllers/project.py defines a class Project, app.py would import it like this:</p>

<pre><code>from app.controllers.project import Project
</code></pre>

<p>I'd like to just be able to do:</p>

<pre><code>from app.controllers import Project
</code></pre>

<p>How would this be done?</p>

<p>You need to put</p>

<pre><code>from project import Project
</code></pre>

<p>in <code>controllers/__init__.py</code>.</p>

<p>Note that when <a href="http://www.python.org/dev/peps/pep-0328/" rel="nofollow">Absolute imports</a> become the default (Python 2.7?), you will want to add a dot before the module name (to avoid collisions with a top-level model named <code>project</code>), i.e.,</p>

<pre><code>from .project import Project
</code></pre>
