<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 10, 2014 at 6:50 PM, Stephen J. Turnbull <span dir="ltr"><<a href="mailto:stephen@xemacs.org" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=stephen@xemacs.org&cc=&bcc=&su=&body=','_blank');return false;">stephen@xemacs.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Chris Lasher writes:<br>
<br>
 > Okay, but a definite -1e6 from me on making my Python interpreter do this:<br>
 ><br>
 >     >>> my_packed_bytes = struct.pack('ffff', 3.544294848931151e-12,<br>
 > 1.853266900760489e+25, 1.6215185358725202e-19, 0.9742483496665955)<br>
 >     >>> my_packed_bytes<br>
 >     b'Why, Guido? Why?'<br>
<br>
</span>If you actually have a struct, why aren't you wrapping<br>
your_packed_bytes in a class that validates the struct and displays it<br>
nicely formatted?  Or, alternatively, simply replaces __repr__?<br></blockquote><div><br></div><div>The point was to demonstrate that although text must be represented by bytes, not all bytes represent text. I have the bytes from four 32-bit floating point numbers, but repr() displays these bytes as ASCII characters. It looks like I wrote "Why, Guido? Why?" illustrating how implicit behavior that's "usually helpful" can be rather unhelpful. Explicitly showing the hexadecimal values is always accurate, because bytes are always bytes.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Your judgment doesn't rule, and it definitely doesn't have a weight of<br>
1e6.</blockquote><div> </div><div>I meant the "-1e6" as a cheeky response, not as a reflection of the importance of my opinions or ideas.</div></div></div></div>