Am 13.01.2014 10:54 schrieb wxjmfa...@gmail.com:

Not at all. I'm afraid I'm understanding Python (on this
aspect very well).

IBTD.

Do you belong to this group of people who are naively
writing wrong Python code (usually not properly working)
during more than a decade?

Why should I be?

'ß' is the the fourth character in that text "Straße"
(base index 0).

Character-wise, yes. But not byte-string-wise. In a byte string, this depends on the character set used.

On CP 437, 850, 12xx (whatever Windows uses) or latin1, you are right, but not on the widely used UTF8.

sys.version
'2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]'
assert 'Straße'[4] == 'ß'
assert u'Straße'[4] == u'ß'

Linux box at home:

Python 2.7.3 (default, Apr 14 2012, 08:58:41) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> assert 'Straße'[4] == 'ß'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError
>>> assert u'Straße'[4] == u'ß'

Python 3.3.0 (default, Oct 01 2012, 09:13:30) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> assert 'Straße'[4] == 'ß'
>>> assert u'Straße'[4] == u'ß'

Windows box at work:

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> assert 'Straße'[4] == 'ß'
>>> assert u'Straße'[4] == u'ß'

PS Nothing to do with Py2/Py3.

As bytes and unicode and str stuff is heavily changed between them, of course it has to do.

And I think you know that and try to confuse and FUD us all - with no avail.


Thomas
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to