3 ms·
This is exactly what I mean. I know I should move binary data around as bytes. I'm not saying I want to (or intend to) move binary data around as strings. I'm
by aeturnum 10y ago
This is exactly what I mean.
I know I should move binary data around as bytes. I'm not saying I want to (or intend to) move binary data around as strings.
I'm saying that, in Python 2, you get a str - which happens to be binary and you don't have to worry about it. Even if it's unicode, it'll still work - it just won't matter. In Python 3, it depends on what the library gives you. Did it give you bytes? Maybe a str? You'll need to check and do the proper conversion to bytes. The behavior that Python 3 forces on you is safer and more correct, but it's behavior that you did not have to go through in Python 2.
Sometimes, in Python 3, the library gives you bytes and you want bytes and you're fine, but it's common that you are not.