title: Conditional import in a module
body: <p>I have created a module modA which I am importing in my main program. Depending on what happens in my main program (it has an interactive mode and a batch script mode), I want modA itself to import matplotlib with either the TkAgg backend or the ps backend. Is there a way for my main program to communicate information to modA to tell it how it should import matplotlib?</p>
  
  <p>To clarify the situation:</p>
  
  <p>The main program:</p>
  
  <pre><code>#if we are in interactive mode
  #import modA which imports matplotlib using TkAgg backend
  #else
  #import modA which imports matplotlib using the ps backend
  </code></pre>
  
  <p>Module modA:</p>
  
  <pre><code>#import matplotlib
  #matplotlib.use('ps') or matplotlib.use('TkAgg') (how can I do this?)
  </code></pre>