On 2014-01-12 08:31, Peter Otten wrote:
wxjmfa...@gmail.com wrote:

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


jmf

Signifying nothing. (Macbeth)

Python 2.7.2+ (default, Jul 20 2012, 22:15:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
s = "Straße"
assert len(s) == 6
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AssertionError
assert s[5] == "e"
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AssertionError


The point is that in Python 2 'Straße' is a bytestring and its length
depends on the encoding of the source file. If the source file is UTF-8
then 'Straße' is a string literal with 7 bytes between the single
quotes.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to