title: code execution upon import in Python
body: <p>When I import a module in my python file, I expect execution of the imported code to be executed when I execute the file that is importing the module.</p>
  
  <p>Here is the code:</p>
  
  <p>I have few simple lines in test_2.py file:</p>
  
  <pre><code>x = 10
  y = 20
  
  c = x-y
  
  print c
  
  def func1():
      return x+y 
  </code></pre>
  
  <p>This is imported in another file test_2_test.py:</p>
  
  <pre><code>import test_2
  x = test_2.func1()
  print x
  </code></pre>
  
  <p>Here is the output when I execute test_2_test:</p>
  
  <blockquote>
    <p>%run "D:/Projects/Initiatives/machine
    learning/programs/test_2_test.py" 30</p>
  </blockquote>
  
  <p>I cannot figure out why "print c" statement is not executed</p>