title: Why does my code work from interactive shell, but not when run from a file?
body: <p>I am trying to use the <code>pprint</code> module to check out some vars in Python, which I can happily do using the interactive shell and the code below:</p>
  
  <pre><code>import pprint
  pp = pprint.PrettyPrinter()
  stuff = ['cakes','bread','mead']
  pp.pprint(stuff)
  </code></pre>
  
  <p>However, when I put the above into <code>pprint.py</code> and run it using <code>python pprint.py</code> I get the error:</p>
  
  <pre><code>$ python dev/pars/pprint.py 
  Traceback (most recent call last):
    File "dev/pars/pprint.py", line 1, in ?
      import pprint
    File "/home/origina2/dev/pars/pprint.py", line 2, in ?
      pp = pprint.PrettyPrinter()
  AttributeError: 'module' object has no attribute 'PrettyPrinter'
  </code></pre>
  
  <p>What is different about the way modules are called when running Python code from a file compared to the interactive shell?</p>