title: Cannot import module when using memory_profiler
body: <p>I'm trying to use <a href="https://pypi.python.org/pypi/memory_profiler" rel="nofollow">memory_profiler</a>, but I run into a problem that is isolated in example.py:</p>
  
  <pre><code>#! /usr/bin/env python 
  import argparse
  
  def parse_args():
      parser = argparse.ArgumentParser(description='Dummy description')
      parser.add_argument('--option',  action='store_true')
      return parser.parse_args() 
  
  if __name__ == '__main__':
      parse_args()
  </code></pre>
  
  <p>So basically only using argparse. Standalone this runs fine (I have Python3.3). However, when I issue</p>
  
  <pre><code>$ python -m memory_profiler example.py
  </code></pre>
  
  <p>I get a the error:</p>
  
  <pre><code>NameError: global name 'argparse' is not defined
  </code></pre>
  
  <p>Furthermore if I put the line </p>
  
  <pre><code>    parser = argparse.ArgumentParser(description='Dummy description')
  </code></pre>
  
  <p>Underneath </p>
  
  <pre><code>    if __name__ == '__main__':
  </code></pre>
  
  <p>And I comment out the function call to parse_args(), then I don't get the error.</p>
  
  <p>Anyone an idea what goes wrong here?</p>