python source code encoding
Reading the python primer at http://docs.python.org/2/tutorial/interpreter.html
I found that "It is possible to use encodings different than ASCII in Python source files." My question; Is there a group of python programmers that do normally change encoding? If so, for what reason(s)? I did google it, and found a lot of interesting info about encoding, but didn't see the more specific info I'm after. Thanks, |
This is done so often, that starting from Python 3 default encoding was changed to UTF-8. The reason is very simple: let's say you want to assign to a variable a Unicode string literal which contains some non-ASCII symbols in it. The example with Euro sign given in the docs section that you link to fits here perfectly:
Code:
foo = u'€' Code:
# -*- coding: utf-8 -*- Code:
File "/tmp/foo.py", line 1 |
Thank you audriusk for the great reply.
|
All times are GMT -5. The time now is 05:27 PM. |