title: Why does python executes imported script without invoking
body: <p>Actually I want to invoke one module in middle of the main script by passing main script output as input for that module, but it is not allowing me to run the main script , it executes the module and raises an error. Any solution?</p>
  
  <p><strong>Main.py</strong></p>
  
  <pre><code>from pic import get_imagepath #this module i m importing
  # after detecting image from webcam i just want to pass it to get_imagepath
  
  get_imagepath(image)
  </code></pre>
  
  <p><strong>Pic.py</strong></p>
  
  <pre><code>def get_imagepath(image):
      ...
      ...
      return imagepath
  
  rgb_image = load_image(image_path, grayscale=True)
  
  
  
  error:
  from pic import get_imagepath
  File "C:\Users\ADMIN\Downloads\#########################\facenet\pic.py", line 42, in 
   &lt;module&gt;
  rgb_image = load_image(image_path, grayscale=True)
  NameError: name 'image_path' is not defined
  </code></pre>
  
  <p>this is the scenario. its directly executing pic script at the time of import and raising error like image_path is not defined. please help me</p>