[IPython-User] file magic and unicode encoding
Wed Apr 10 11:17:47 CDT 2013
On 10 April 2013 15:55, epi <email@example.com> wrote:
> SyntaxError: Non-ASCII character '\xc2' in file esadict.py on line 4, but
> no encoding declared; see http://www.python.org/peps/pep-0263.html for
> seems that %%file is saving without unicode encoding
> is it possible to specify the encoding to %%file ?
It's saving the text you give it. But without an encoding declaration, your
file is not valid in Python 2. The first or second line needs to look like:
# coding: utf-8
The %save magic, which is designed for Python code, adds this
automatically. But the %%file magic is for writing arbitrary text, so it
doesn't check or change the text before saving it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User