title: How do I have two scripts reference the same module
body: <p>I'm writing two scripts which are intended to be run from the command line.  Let's call them <code>foo.py</code> and <code>bar.py</code>.  In addition, I have a utility module called <code>util</code> which is to be shared by both of these scripts.  How do I structure my code so that <code>foo</code> and <code>bar</code> can both have a simple line like <code>import util</code>?  Currently, my directory structure is like this:</p>
  
  <pre><code>MyProject
  \--foo
     \--foo.py
     \--foo_util.py
  \--bar
     \--bar.py
     \--bar_util.py
  \--util
     \--util.py
  </code></pre>
  
  <p>Within <code>foo</code>, I want to be able to write <code>import foo_util</code> and <code>import util</code> but I dont' want to be able to write <code>import bar</code>, because they are independent programs which have no reason to use each others' code.</p>
  
  <p>Update: A slightly modified version of chepner's solution, I've found something that seems to work for me.  My project is now structured like this:</p>
  
  <pre><code>MyProject
     \--__init__.py
     \--foo.py
     \--bar.py
     \--MyProject
        \--__init__.py
        \--foo
           \--__init__.py
           \--foo_impl.py
        \--bar
           \--__init__.py
           \--bar_impl.py
        \--shared
           \--__init__.py
           \--util.py
  </code></pre>
  
  <p><code>foo.py</code> can write <code>import MyProject.foo as foo</code> and <code>bar.py</code> can do something similar, and both <code>foo</code> and <code>bar</code> can do <code>import MyProject.shared</code></p>