License Public Domain
Lines 2
Keywords
default (1) encoding (1) file (4) python (33) UTF-8 (1)
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Know what you're getting – Unlike many sites, all our code is clearly licensed. Join Siafoo Now or Learn More
Note: You are viewing an old version of this snippet. View Latest Version

Set Default Python File Encoding Atom Feed 1

In Brief Set Python to always assume UTF-8 file encodings by saving this in your site-packages directory.... more
# 's
1import sys
2sys.setdefaultencoding('utf-8')
Getting an error like this?
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

Set Python to always assume UTF-8 file encodings by saving this in your site-packages directory.