What encoding does u'...' syntax use?

Terry Reedy tjreedy at udel.edu
Fri Feb 20 20:38:39 EST 2009


Martin v. Löwis wrote:
mehow have picked up a latin-1 encoding.)
>> I think latin-1 was the default without a coding cookie line.  (May be
>> uft-8 in 3.0).
> 
> It is, but that's irrelevant for the example. In the source
> 
>   u'\xb5'
> 
> all characters are ASCII (i.e. all of "letter u", "single
> quote", "backslash", "letter x", "letter b", "digit 5").
> As a consequence, this source text has the same meaning in all
> supported source encodings (as source encodings must be ASCII
> supersets).

I think I understand now that the coding cookie only matters if I use an 
editor that actually stores *non-ascii* bytes in the file for the Python 
parser to interpret.




More information about the Python-list mailing list