<br>This is because a bytes object is not a sequence of bytes objects, like strings. It's a sequence of small integer values, so you need to assign a small integer value to it. You can assign b'a'[0] to it, or assign b'a' to x[:1]. I guess we could specialcase length-1 bytes to make this work 'naturally', but I'm not sure that's the right approach. Guido?
<br><br><div><span class="gmail_quote">On 2/25/07, <b class="gmail_sendername">Neil Schemenauer</b> <<a href="mailto:nas@arctrix.com">nas@arctrix.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>>> x = b'a'<br>>>> x[0] = b'a'<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>TypeError: 'bytes' object cannot be interpreted as an index
<br><br>Huh? 0 is not a 'bytes' object and I don't see how the RHS is being<br>used as an index. Obviously I wanted something like:<br><br>>>> x[0] = ord(b'a')<br><br>_______________________________________________
<br>Python-3000 mailing list<br><a href="mailto:Python-3000@python.org">Python-3000@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/python-3000">http://mail.python.org/mailman/listinfo/python-3000</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-3000/thomas%40python.org">http://mail.python.org/mailman/options/python-3000/thomas%40python.org</a><br></blockquote></div><br><br clear="all"><br>-- <br>
Thomas Wouters <<a href="mailto:thomas@python.org">thomas@python.org</a>><br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!