title: (Python) How to import from external projects that share same submodule names?
body: <h2>Setup</h2>
  <p>Suppose I am making use of two other people's <em>complex</em> projects, cloned from Github, called <code>foo</code> and <code>bar</code>, that both contain subdirectories of the same name. Importantly, <code>foo</code> and <code>bar</code> are complex and they contain many code that assume their own project structure. Specifically, none of the two projects are setup as a Python package.</p>
  <p>As an example, my project structure as well as the structure of the external projects is:</p>
  <pre><code>project_root/
      myprog.py
      external/
          foo/
              models/
              ... # other code that involve `import models...`
          bar/
              models/
              ... # other code that involve `import models...`
  </code></pre>
  <p>where <code>external/foo</code> and <code>external/bar</code> are essentially git submodules for my own project.</p>
  <p>In particular, both <code>foo</code> and <code>bar</code> have other code that may contain something like:</p>
  <pre><code>import models.some_model.some_stuff  
  ...
  </code></pre>
  <p>(note that even if the above code appear in subdirectories of <code>foo</code> or <code>bar</code>, it is still ok for that project, because, for example, their intended usage involves loading the project's path into <code>sys.paths</code>)</p>
  <h2>My Question</h2>
  <p>Let's say I am coding my <code>myprog.py</code>. I know that if all I want to do is to import a module from <code>foo</code>, I could:</p>
  <ol>
  <li>Create a symbolic link to the <code>foo</code> project under <code>project_root</code> directory</li>
  <li>Add path to <code>external/foo</code> into my <code>sys.path</code>, like so
  <pre><code># myprog.py
  import sys
  sys.path.append(&quot;absolute/path/to/external/foo&quot;)
  </code></pre>
  </li>
  </ol>
  <p>The first step allows me to do:</p>
  <pre><code># myprog.py
  from foo import ...
  </code></pre>
  <p>while the second step essentially preserves the validity of <code>foo</code>'s own code with <code>import models...</code> because now <code>models</code> is part of my <code>sys.path</code>.</p>
  <p>However, <strong>how to do this when there are two external projects that share the same submodule names</strong>?</p>
  <p>Because of name conflict, if I add the path to both projects into my <code>sys.path</code>, then it is ambiguous what <code>import models</code> means and will break the external projects' code.</p>
  <p>I hope my question is clear. I think there must be a way to do this as people are reusing other people's code all the time.</p>