title: Importing from nameclashing packages which structure differs?
body: <p>I have a package <code>foo</code> laid out like so:</p>
  
  <pre><code>.
  └── foo
      ├── bar.py
      └── __init__.py
  </code></pre>
  
  <p>However, I have another package named <code>foo</code> in my <code>$PYTHONPATH</code>, laid out like so:</p>
  
  <pre><code>.
  └── foo
      ├── qux.py
      └── __init__.py
  </code></pre>
  
  <p>All I really care about is importing <code>bar</code> from the former, and <code>qux</code> from the latter.</p>
  
  <p>Is there a reasonably clean way to do that without resolving the conflict?  Specifically, taking advantage of the fact that the pacakges have a different structure despite sharing the same name?  (Specifically, the first contains a nested <code>bar</code>, the second a nested <code>qux</code>).</p>
  
  <p>For example, if there was a way to <code>import foo</code> and get <em>all</em> the matching <code>foo</code> packages in a list, rather than just the first one in the <code>$PYTHONPATH</code>, I could iterate over them and test for <code>hasattr(package, 'bar')</code>.</p>
  
  <p>It's legitimate to answer that this can't work, and there's no way to handle such a nameclash - i.e. more than one package in the <code>$PYTHONPATH</code> having the exact same name.</p>