4 ms·
Hmm... I guess that makes me a liar too. powerbook.local 104> cat > foo.py # -*- coding: <utf-8> -*- def ô(): return "ô" powerbook.local 105> python
by bayareaguy 19y ago
Hmm... I guess that makes me a liar too.
powerbook.local 104> cat > foo.py
# -*- coding: <utf-8> -*-
def ô():
return "ô"
powerbook.local 105> python foo.py
File "foo.py", line 2
SyntaxError: Non-ASCII character '\xc3' in file foo.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
powerbook.local 106>
Now if you actually go look at the web page in the error message, you should notice that the encoding doesn't include the < >.
But even when the encoding is set properly python still complains:
powerbook.local 106> cat > foo.py
# -*- coding: utf-8 -*-
def ô():
return "ô"
powerbook.local 107> python foo.py
File "foo.py", line 2
def ô():
^
SyntaxError: invalid syntax
powerbook.local 108>
- anewaccountname 19y agoAre you sure you don't mean 'cat foo.py' or maybe 'cat - < foo.py'?
- bayareaguy 19y agoYes, I'm sure. cat > foo.py copies standard input into the file foo.py. The rest of the characters you're seeing in the message are what I typed in. The only character you don't see is the Ctrl-D I type to indicate EOF. This is a quick and easy way of creating foo.py without using an editor.
- anewaccountname 19y agoAh, now I see.