If module `example` contains both function `run` and submodule `run`, can I count on `from example import run` to always import the former?
<p>If I have a Python module implemented as a directory (i.e. package) that has both a top level function <code>run</code> and a submodule <code>run</code>, can I count on <code>from example import run</code> to always import the function? Based on my tests that is the case at least with Python 2.6 and Jython 2.5 on Linux, but can I count on this generally? I tried to search information about the import priorities but couldn't find anything.</p>

<p>Background:</p>

<p>I have a pretty large package that people generally run as a tool from the command line but also sometimes use programmatically. I would like to have simple entry points for both usages and consider to implement them like this:</p>

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

<pre><code>def run(*args):
    print args  # real application code belongs here
</code></pre>

<p><code>example/run.py</code>:</p>

<pre><code>import sys
from example import run
run(*sys.argv[1:])
</code></pre>

<p>The first entry point allows users to access the module from Python like this:</p>

<pre><code>from example import run
run(args)
</code></pre>

<p>The latter entry point allows users to execute the module from the command line using both of the approaches below:</p>

<pre><code>python -m example.run args
python path/to/example/run.py args
</code></pre>

<p>This both works great and covers everything I need. Before taking this into real use, I would like to know is this a sound approach that I can expect to work with all Python implementations on all operating systems.</p>
