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