title: Python - View an imported module's dotted import
body: <p>I want to get all the modules imported from an arbitrary module <code>m</code>.
  When <code>m</code> imports a module in the following way:</p>
  
  <pre><code>from a.b import c
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>import a.b.c as c
  </code></pre>
  
  <p>(where <code>a</code> and <code>b</code> are packages, and <code>c</code> is a module)</p>
  
  <p>The result of <code>dir(m)</code> would contain <code>c</code> (among other things).</p>
  
  <p>However, when I use:</p>
  
  <pre><code>import a.b.c
  </code></pre>
  
  <p>The result of <code>dir(m)</code> would contain <code>a</code>, and not <code>c</code>.</p>
  
  <p>I also tried iterating over <code>sys._getframe(1).f_locals.items()</code> after importing <code>m</code>, but got the same result.
  How can I, having the object of <code>m</code> that imports <code>c</code> that way, know that it actually imported <code>c</code>?</p>