Import issues when importing stuff from package root's __init__.py
<p>I think I'm misunderstanding something about the way the import system works when you throw <code>__init__.py</code> into the mix.  Here's my (very streamlined for this example) layout (Python 3.5):</p>

<pre><code>adminproj/
  __init.__py
  main.py
  functions/
    password.py
</code></pre>

<p>In <code>adminproj.__init__.py</code>, I've defined two components with the intention of using them globally (in main.py and functions.password.py):</p>

<pre><code>with open((os.path.dirname(__file__)) + "/config/dev.yml", 'r') as ymlfile:
    config = yaml.load(ymlfile)

logger = logging.getLogger("adminproj")
# followed by a bunch of log customization
</code></pre>

<p>Now in my scripts, both main.py and password.py, I can do this:</p>

<pre><code>from adminproj import config
from adminproj import logger
logger.info("config values: " + str(config))
</code></pre>

<p>Horray!</p>

<p>But I also want to make my function calls not require fully qualified module names, by adding this into <code>adminproj.__init__.py</code>:</p>

<pre><code>from adminproj.functions.password import *
</code></pre>

<p>Now when I do this, everything blows to hell, specifically I get problems with importing "logger" and "config":</p>

<pre><code>&gt;&gt;&gt; import adminproj
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/admin/sandbox/adminproj/adminproj/__init__.py", line 12, in &lt;module&gt;
    from adminproj.functions.password import *
  File "/admin/sandbox/adminproj/adminproj/functions/password.py", line 3, in &lt;module&gt;
    from adminproj import logger
ImportError: cannot import name 'logger'
</code></pre>

<p>I'm pretty sure it has something to do with a name collision or something, e.g. when <code>__init__.py</code> imports something which itself imports something that <code>__init__.py</code> declares.  Even if that's the right frame of mind, I can't seem to figure out a solution to do what I want to do.  Perhaps using <code>__init__.py</code> as a global namespace is in bad form.</p>

<p>The simple solution is to just forget <code>from functions.password import *</code> and use fully qualified imports.  But I want to make my function calls short and sweet, yet still utilize the global variables in <code>__init__.py</code>.</p>

<pre><code>adminproj.contains_profanity("badword")
</code></pre>

<p>versus.</p>

<pre><code>adminproj.functions.password.contains_profanity("badword")
</code></pre>