title: handle non ascii code string in python
body: <p>It is really confusing to handle non-ascii code char in python. Can any one explain?</p>
  
  <p>I'm trying to read a plain text file and replace all non-alphabetic characters with spaces.</p>
  
  <p>I have a list of characters:</p>
  
  <pre><code>ignorelist = ('!', '-', '_', '(', ')', ',', '.', ':', ';', '"', '\'', '?', '#', '@', '$', '^', '&amp;', '*', '+', '=', '{', '}', '[', ']', '\\', '|', '&lt;', '&gt;', '/', u'—')
  </code></pre>
  
  <p>for each token i got, i replace any char in that token with space by calling</p>
  
  <pre><code>    for punc in ignorelist:
          token = token.replace(punc, ' ')
  </code></pre>
  
  <p>notice there's a non ascii code character at the end of <code>ignorelist</code>: <code>u'—'</code></p>
  
  <p>Everytime when my code encounters that character, it crashes and say:</p>
  
  <pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
  </code></pre>
  
  <p>I tried to declare the encoding by adding <code># -*- coding: utf-8 -*-</code> at the top of the file, but still not working. anyone knows why? Thanks!</p>