4 ms·
You encode from a Unicode string to bytes and decode from bytes to a Unicode string. Remember that things like "utf8" and "ascii" are so called "encodings" of U
by js2 4y ago
You encode from a Unicode string to bytes and decode from bytes to a Unicode string. Remember that things like "utf8" and "ascii" are so called "encodings" of Unicode. Base64 is also an encoding (of bytes to ascii).
Now the terms encode and decode may be jargon, but they are not terms that Python made up. This is standard terminology for our industry.
I understand you find them arcane and unclear. I'm not trying to convince you otherwise. Which is why I suggested the alternative of using bytes("", encoding) and str(b"", encoding) as an option that you might find more clear.
Maybe Python should have named these to_bytes() and to_string() instead. I can't argue against that. I'm only saying that I don't find encode/decode unclear and that they are standard industry terminology.
- andrewstuart 4y agoI'm not asking you to explain it to me. You explaining does not make the commands easy. I'm addressing the point that you made that the commands are obvious, they're not. I was asking you to identify all the permutations because that is what makes those commands complex and need constant looking up.