[Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3

Stephen J. Turnbull stephen at xemacs.org
Thu Sep 11 04:17:19 CEST 2014


Nick Coghlan writes:

 > In Python 3, "bytes" is still a hybrid type that can hold:
 > * arbitrary binary data
 > * binary data that contains ASCII segments
 > 
 > A pure teaching language wouldn't make that compromise.

Of course it would, because nobody in their right mind would restrict
a bytes type to the values 128-255!

Yes, I know what you mean: it wouldn't use the hybrid representation
for repr or for literals.  My point is that even you are making the
mistake of framing the issue as whether a bytes object is "arbitrary
binary data" or "binary data that contains [readable] ASCII segments"
as something inherent in the type.  It's not!

It's all about convenience of representation for particular
applications, end of story.  A repr that obfuscates the content in the
"ASCII segment" set of applications *might* be preferable for teaching
applications, but I'm not even sure of that.



More information about the Python-ideas mailing list