"Jason Orendorff" firstname.lastname@example.org writes:
I gather that "coding:" is supposed to specify the encoding (what MIME calls "charset") of the file. But under PEP 263, it only refers to the Unicode string literals within the program. Everything else must still be treated as 8-bit text.
Not really. If you are willing to separate the language and its implementation, then I'd phrase the intent that way:
For example, I'm not sure what effect "coding: utf-16" would have. (?)
Invalid; source encodings must be an ASCII superset (not sure how the implementation will react to that; if the file really is UTF-16, you'll get a syntax error, if you say it is UTF-16 but it isn't, Python will reject it in phase 2).
For another example, if you have UTF-8 Unicode string literals in your program but you also have 8-bit Latin-1 plain str string literals in the same program, how should you mark it?
You should mark the file as UTF-8. In phase 2, Python will reject it. At that point, you should convert your latin-1 string literal into hex escapes - it is binary data then, not Latin-1.
How will Emacs then treat it?
Don't know - just try. You cannot create such a file with Emacs.
Is a Python program an 8-bit string or a Unicode string?