title: An imported function no longer works after another import is done
body: <p>So this is what I'm dealing with:</p>
  <blockquote>
  <p>I have a module A, where</p>
  <ul>
  <li>submodule A.B contains a function called &quot;func1&quot;</li>
  <li>submodule A.B.C contains a function called &quot;func2&quot;</li>
  </ul>
  <p>I also have a separate module B with an class C</p>
  <p>Lastly, A.B.func1 uses class C from module B, through the import statement &quot;from B import C&quot;</p>
  </blockquote>
  <p>What I've learned so far is that, if I just do:</p>
  <pre><code>from A.B import func1
  </code></pre>
  <p>func1 will work.</p>
  <p>However, if I were to do:</p>
  <pre><code>from A.B import func1
  from A.B.C import func2
  </code></pre>
  <p>func1 will not work.</p>
  <p>After digging around and trying stuff, I've found that A.B.func1's usage of C would look at func1's globals to find C (put there by its &quot;from B import C&quot;). However, the entry for C in the globals is overwritten when &quot;from A.B.C import func2&quot; is executed. Basically, the fact that I have both A.B.C and B.C is confusing the global namespace and thus causing this unexpected failure, despite that within each module the code looks correct.</p>
  <p>However, I'm at a loss for how to prevent this from happening in the future. What naming rules/conventions should I follow to prevent something like this happening? A drastic solution might be to make sure you never have two submodules with the same name, but I would imagine with a large enough library system this may be difficult to upkeep. What does everyone else do in this situation?</p>
  <p>Perhaps I should be using imports differently, and do something other than &quot;from ... import ...&quot;?</p>
  <p>Any comments/help would be greatly appreciated.</p>