Hide
Know what you're getting – Unlike many sites, all our code is clearly licensed. Join Siafoo Now or Learn More

Set Default Python File Encoding

Revision 2 vs. Revision 3

Legend:

Unmodified
Added
Removed
  • Description

    r2 r3  
    11Getting an error like this?  
     2  
    23  SyntaxError: Non-ASCII character '\xe2' in file /some/file on line 13, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details  
    34  
    4 Set Python to always assume UTF-8 file encodings by saving this in your site-packages directory. 
     5Set Python to always assume UTF-8 file encodings by saving this in your site-packages directory.  
     6  
     7If you're still getting an error, or want to set encodings per file, add this to the top of your file:  
     8  
     9.. code:: python  
     10  
     11    # -*- coding: utf-8 -*-