Force importing module from current directory
<p>I have package <code>p</code> that has modules <code>a</code> and <code>b</code>. <code>a</code> relies on <code>b</code>:</p>

<p><code>b.py</code> contents:</p>

<pre><code>import a
</code></pre>

<p>However I want to <em>ensure</em> that <code>b</code> imports my <code>a</code> module from the same <code>p</code> package directory and not just any <code>a</code> module from <code>PYTHONPATH</code>.</p>

<p>So I'm trying to change <code>b.py</code> like the following:</p>

<pre><code>from . import a
</code></pre>

<p>This works as long as I import <code>b</code> when I'm outside of <code>p</code> package directory. Given the following files:</p>

<pre><code>/tmp
    /p
       a.py
       b.py
       __init__.py
</code></pre>

<p>The following works:</p>

<pre><code>$ cd /tmp
$ echo 'import p.b' | python
</code></pre>

<p><strong>The following does NOT work:</strong></p>

<pre><code>$ cd /tmp/p
$ echo 'import b' | python
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "b.py", line 1, in &lt;module&gt;
    from . import a
ValueError: Attempted relative import in non-package
</code></pre>

<p><strong>Why?</strong></p>

<p>P.S. I'm using Python 2.7.3</p>
