1
1
I'm using OSX Yosemite on a Macbook Pro with a UK keyboard. When I type #
into a Python file (using Alt+3) I sometimes, but not always, see this syntax error when I try to run the Python file:
SyntaxError: Non-ASCII character '\xc2' in file
I can usually fix it by copying and pasting a hash character from elsewhere in the file.
I could fix it by manually setting every Python I ever work on to UTF-8 encoding:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
but that's not really practical when I'm working on other people's code.
Is there any way I can reset the value of this key to an ASCII-friendly #
to avoid this error?
1Which editor are you using? – Matteo – 2015-03-20T11:47:28.963
Sorry, I'm using Sublime. – Richard – 2015-03-23T18:24:33.240
(That's Sublime Text 3.) – Richard – 2015-04-22T11:21:31.763
Did you ever make any progress? This happens to me too and you're the only one I've found with the same problem. Wracking my brain trying to work it out, it's like it inserts an invisible character which Python bails on. You using the wireless keyboard? – AndyC – 2015-07-28T11:50:10.540