4 ms·
I have a hard time believing that the design was arbitrarily changed. The request to add string-APIs to the bytes object have been brought up before [0]. I thi
by agentultra 13y ago
I have a hard time believing that the design was arbitrarily changed.
The request to add string-APIs to the bytes object have been brought up before [0]. I think the reasoning is quite clear: byte-strings are not textual objects. If you are sending textual-data to a byte-string API, build your string as a string and encode it to bytes.
[0] http://bugs.python.org/issue3982 http://bugs.python.org/issue3982
For working with binary data there's a much cleaner API in Python 3 that is less prone to subtle encoding errors.
edit: I realize there is contention but I'm of the mind that .format probably isn't the right method and that if there were one it'd need it's own format control string syntax.