Encoding errors in *comments*??

I'm new to python. I wrote the following code, and it ran fine on one unix machine and on learnpython.org. Then I scp'd it to another machine, and I get encoding errors (below). I have searched and found many posts about encoding issues when using strings, and the use of the '# coding=utf-8" directive, however my code doesn't use any strings, it simply does a little math. Furthermore, the encoding errors seem to appear on *comment* lines. ??

% ./binsearch.py
File "./binsearch.py", line 3
SyntaxError: Non-ASCII character '\xc2' in file ./binsearch.py on line 3, but no encoding declared; see (URL blocked: see forum rules) for details

How can I change some python config file on this system to make these errors disappear? It's just a simple text file. I even copied & pasted via mouse-highlighting within a simple text editor in order to eliminate any potential "magic" invisible characters, but the error persists.

If I add the '#coding=utf-8' line -- which I believe I "shouldn't" have to do, and this is why I'm posting this thread -- then I get a new error that seems to be due to the fact that I used spaces (3 spaces, exactly, for each indent) instead of tabs. I thought spaces OR tabs were allowed. Yay or nay?

The encoding error isn't anything to do with strings (that would be a UnicodeError at runtime, not a syntax error). It's a problem with the encoding of the source code itself -- the interpreter needs to be able to parse that, after all. By default, Python 2 expects ASCII, and you'll have to declare an encoding if that's not what you're using. (Python 3 uses UTF-8 as the source encoding by default.)

That being said, I don't see any non-ASCII characters on line 3.

As for tabs, yes, either tabs or spaces are accepted; you should only get an error if you're being inconsistent. Not really sure what's up there.

Hi
I had that kind of trouble when switching between text editor (gedit and komodo for example). I think you should verify what is the default encoding in each of the text editors you used. Because even if you don't use any specific characters from ASCII or UT8, if the file is declared UT8 and is in fact ASCII, Python will bug.