When I run the same code with different pipelines, why is the output different?
% python2.7 -c 'import sys; print sys.stdout.encoding' UTF-8 % python2.7 -c 'import sys; print sys.stdout.encoding' | cat None
Because when you use cat (or any channel), you untie the process from the terminal. Python gets encoding information from terminal settings.
cat
You can force the encoding to use an environment variable:
export PYTHONIOENCODING=utf-8