How to import custom module the same way as pip-installed modules?
<p>I feel really dumb asking this question, but it's a quirk of python I've put up with for awhile now that I finally want to fix.</p>

<p>On CentOS 7, given that I have "roflmao.py" and "__init__.py" in the directory:</p>

<pre><code> /usr/lib/python2.7/site-packages/roflmao
</code></pre>

<p>Why is it that when I'm using the python interpreter (and not in the directory containing roflmao.py), I must type:</p>

<pre><code>from roflmao import roflmao
</code></pre>

<p>Instead of simply:</p>

<pre><code>import roflmao
</code></pre>

<p>To gain access to "roflmao.py"'s functions and variables?  I can import re, collections, requests, or any PIP-installed module just fine, but not my own custom one.</p>

<p>How can I set things up to accomplish this?</p>

<p>Put <code>from roflmao import *</code> into <code>__init__.py</code>.</p>

<p>If you do this, then you don't really need to use <code>roflmao.py</code>.  Because it would then be pointless to do <code>from roflmao import roflmao</code>.  So it's best to just put the code from <code>roflmao.py</code> into <code>__init__.py</code>.</p>

python import module