title: Import/execute a module and call function from parent module
body: <p>I'm trying to call an external python script from my django app. I want to call a function from the parent module in the external python script. I tried the following ways.</p>
  
  <ol>
  <li><p>Using subprocess.call : In this case, i'm not able to use the functions from the parent file. The target function uses Django models to do some db operations.</p></li>
  <li><p>Import external file : I tried importing the external file using <strong>import</strong>(), but i cannot access the functions defined in the parent module.</p></li>
  </ol>
  
  <p>Sample code :</p>
  
  <pre><code>from app.models import x
  
  def save():
      print x.objects.all()    
  
  def do_stuff():
      subprocess.call('external_script')
  
  
  #----------External script --------
  ''' some code here '''
  
  #Calling save function from parent 
  save()
  </code></pre>
  
  <p>How do i achieve this?</p>