<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[bytearray, type and format confusion]]></title><description><![CDATA[<p dir="auto">Hello, I could really use a hint here as to understand the type bytearray which I'm using for sending to a java socket on an rpi.</p>
<p dir="auto">In REPL console I typed this:</p>
<pre><code>data = bytearray()
print(data)
**bytearray(b'')**
data.append(40000)
print(data)
**bytearray(b'@')**
print(data, encoding='utf8')
**bytearray(b'@')**
</code></pre>
<p dir="auto">What format is this? How come that the int 40000 is shown as '@' ?? It's not hexadecimal and it's not a byte (0-255), but obviously there's something I don't get..</p>
]]></description><link>https://forum.pycom.io/topic/2058/bytearray-type-and-format-confusion</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 01:34:53 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/2058.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 31 Oct 2017 16:01:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to bytearray, type and format confusion on Tue, 31 Oct 2017 20:28:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello, I could really use a hint here as to understand the type bytearray which I'm using for sending to a java socket on an rpi.</p>
<p dir="auto">In REPL console I typed this:</p>
<pre><code>data = bytearray()
print(data)
**bytearray(b'')**
data.append(40000)
print(data)
**bytearray(b'@')**
print(data, encoding='utf8')
**bytearray(b'@')**
</code></pre>
<p dir="auto">What format is this? How come that the int 40000 is shown as '@' ?? It's not hexadecimal and it's not a byte (0-255), but obviously there's something I don't get..</p>
]]></description><link>https://forum.pycom.io/post/12253</link><guid isPermaLink="true">https://forum.pycom.io/post/12253</guid><dc:creator><![CDATA[soren]]></dc:creator><pubDate>Tue, 31 Oct 2017 20:28:06 GMT</pubDate></item><item><title><![CDATA[Reply to bytearray, type and format confusion on Tue, 31 Oct 2017 16:05:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/1042">@soren</a> Add ```  alone on the lines before and after your code, or prefix them all with 4 spaces to have them formatted as code.</p>
<p dir="auto"><code>40000 % 256</code> (or <code>40000 &amp; 255</code>, i.e. keeping the 8 least significant bits) = 64, which is the code point for <code>@</code>.</p>
]]></description><link>https://forum.pycom.io/post/12254</link><guid isPermaLink="true">https://forum.pycom.io/post/12254</guid><dc:creator><![CDATA[jcaron]]></dc:creator><pubDate>Tue, 31 Oct 2017 16:05:24 GMT</pubDate></item></channel></rss>