title: Where is module being imported from?
body: <p>Assuming I have two Python modules and path_b is in the import path:</p>
  
  <pre><code># file: path_b/my_module.py
  print "I was imported from ???"
  
  #file: path_a/app.py
  import my_module
  </code></pre>
  
  <p>Is it possible to see where the module is imported from? I want an output like "I was imported from path_a/app.py", if I start app.py (because I need the file name).</p>
  
  <p><strong>Edit:</strong>
  For better understanding; I could write:</p>
  
  <pre><code># file: path_b/my_module.py
  def foo(file):
      print "I was imported from %s" % file
  
  #file: path_a/app.py
  import my_module
  my_module.foo(__file__)
  </code></pre>
  
  <p>So the output would be:</p>
  
  <pre><code>$&gt; python path_app.py
  I was imported from path_a/app.py
  </code></pre>