subtraction is giving me a syntax error

Baptiste Carvello baptiste13z at free.fr
Mon Mar 15 14:43:53 EDT 2010


Joel Pendery a écrit :
> So I am trying to write a bit of code and a simple numerical
> subtraction
> 
> y_diff = y_diff-H
> 
> is giving me the error
> 
> Syntaxerror: Non-ASCII character '\x96' in file on line 70, but no
> encoding declared.
> 
> Even though I have deleted some lines before it and this line is no
> longer line 70, I am still getting the error every time.  I have tried
> to change the encoding of the file to utf-8 but to no avail, I still
> am having this issue.  Any ideas?
> 
> Thanks in advance

Hello,

I would say that when you press the minus key, your operating system doesn't 
encode the standard (ASCII) minus character, but some fancy character, which 
Python cannot interpret.

More precisely, I suspect you are unsing Windows with codepage 1252 (latin 1). 
With this encoding, you have 2 kinds of minus signs: the standard (45th 
character, in hex '\x2d') and the non-standard (150th character, in hex '\x96').

cf:
http://msdn.microsoft.com/en-us/library/cc195054.aspx

Cheers,
Baptiste




More information about the Python-list mailing list