[Python-3000] Weird error message from bytes type

Neil Schemenauer nas at arctrix.com
Mon Feb 26 00:25:38 CET 2007

>>> x = b'a'
>>> x[0] = b'a'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'bytes' object cannot be interpreted as an index

Huh?  0 is not a 'bytes' object and I don't see how the RHS is being
used as an index.  Obviously I wanted something like:

>>> x[0] = ord(b'a')

More information about the Python-3000 mailing list