Re: 'Straße' ('Strasse') and Python 2

wxjmfauth at gmail.com wxjmfauth at gmail.com
Mon Jan 13 11:24:09 EST 2014


Le lundi 13 janvier 2014 11:57:28 UTC+1, Chris Angelico a écrit :
> On Mon, Jan 13, 2014 at 9:38 PM, Steven D'Aprano
> 
> <steve+comp.lang.python at pearwood.info> wrote:
> 
> > I think you are using "from __future__ import unicode_literals".
> 
> > Otherwise, that cannot happen in Python 2.x.
> 
> >
> 
> 
> 
> Alas, not true.
> 
> 
> 
> >>> sys.version
> 
> '2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]'
> 
> >>> sys.maxunicode
> 
> 65535
> 
> >>> assert 'Straße'[4] == 'ß'
> 
> >>> list('Straße')
> 
> ['S', 't', 'r', 'a', '\xdf', 'e']
> 
> 
> 
> That's Windows XP. Presumably Latin-1 (or CP-1252, they both have that
> 
> char at 0xDF). He happens to be correct, *as long as the source code
> 
> encoding matches the output encoding and is one that uses 0xDF to mean
> 
> U+00DF*. Otherwise, he's not.
> 
> 

You are right. It's on Windows. It is only showing how
Python can be a holy mess.

The funny aspect is when I'm reading " *YOUR* assertions
are false" when I'm presenting *PYTHON* assertions!

jmf



More information about the Python-list mailing list