I have a Python script called a.py:
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
print u''
In both bash and tcsh:
$ a.py
Ô£øÔ£øÔ£øÔ£ø
$ echo `a.py`
Traceback (most recent call last):
File "a.py", line 3, in <module>
print u'Ô£øÔ£øÔ£øÔ£ø'
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
The error is coming from Python, not the shell. How can running the script under backticks affect the script itself? Note that this is not a problem if I switch the interpreter to Python 3 at the beginning of the script.