[IPython-User] file magic and unicode encoding

epi massimodisasha@gmail....
Wed Apr 10 09:55:23 CDT 2013

Trying to save some text that contains unicode char in the IPython Notebook using the %%file magic,

i got this error :

%%file esadict.py
ESA = {}
key = 'ERSST-NES'
ESA[key] = {}
ESA[key]['descriptive_text'] = u'1°C.'
Overwriting esadict.py
from esadict import esa
File "esadict.py", line 4
    ESA[key]['header_image'] = u'http://epi.whoi.edu/ipython/results/mdistefano/advisory_01.png'
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 details

 seems that %%file is saving without unicode encoding
is it possible to specify the encoding to %%file ?



More information about the IPython-User mailing list