Relative Python Modules
<p>I am having a lot of trouble understanding the python module import system.</p>

<p>I am trying to create a simple folder structure as follows.</p>

<pre><code>SomeModule
   __init__.py
   AnotherModule
       AnotherModule.py
       __init__.py
       Utils
           Utils.py
           __init__.py
</code></pre>

<p>To use SomeModule i can do:</p>

<pre><code>SomeModule.Foo()
</code></pre>

<p>Now inside AnotherModule.py I would like to import my Utils directory.</p>

<p>How come I have to do</p>

<pre><code>import SomeModule.AnotherModule.Utils.Foo
</code></pre>

<p>why cannot I just do</p>

<pre><code>import Utils.Foo
</code></pre>

<p>put</p>

<pre><code>import sys
import SomeModule.AnotherModule
sys.modules['AnotherModule'] = SomeModule.AnotherModule
</code></pre>

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

python python-2.7