Python: relative import imports whole package
<p>I just noticed that relative import like this:</p>

<pre><code>from .foo import myfunc
print myfunc  # ok
print foo  # ok
</code></pre>

<p>imports both foo and myfunc. Is such behaviour documented anywhere? Can I disable it?</p>

<p>-- Update</p>

<p>Basically problem is following.</p>

<p><code>bar/foo/__init__.py</code>:</p>

<pre><code>__all__ = ['myfunc']

def myfunc(): pass
</code></pre>

<p><code>bar/__init__.py</code>:</p>

<pre><code>from .foo import *
# here I expect that there is only myfunc defined
</code></pre>

<p><code>main.py</code>:</p>

<pre><code>import foo
from bar import *  # this import shadows original foo
</code></pre>

<p>I can add <code>__all__</code> to the <code>bar/__init__.py</code> as well, but that way I have to repeat names in several places.</p>
