bytes vs. characters
bytes vs. characters
Posted Apr 17, 2015 7:15 UTC (Fri) by zyga (subscriber, #81533)In reply to: bytes vs. characters by Cyberax
Parent article: Report from the Python Language Summit
You can decode("UTF-8", "ignore") or something else to "coerce" it to some form of text though I really do value the sanity of that. Just fix your data sources. Even if you use some 3rd party library it's not going to make any of that "json"-like thing work with other libraries (I assume that other customers/APIs need to read it).
HTTP headers are a perfect example of binary data. Handling them as unicode text is broken IMHO. You can just use byte processing for everything there and Python 3.4, AFAIR, fixed some last gripes about lack of formatting support for edge cases like that.
