[Python-Dev] bytes.from_hex() (original) (raw)
Bob Ippolito bob at redivi.com
Sat Feb 18 06:10:04 CET 2006
- Previous message: [Python-Dev] bytes.from_hex()
- Next message: [Python-Dev] bytes.from_hex()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Feb 17, 2006, at 8:33 PM, Josiah Carlson wrote:
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
Stephen J. Turnbull wrote:
"Guido" == Guido van Rossum <guido at python.org> writes: Guido> - b = bytes(t, enc); t = text(b, enc) +1 The coding conversion operation has always felt like a constructor to me, and in this particular usage that's exactly what it is. I prefer the nomenclature to reflect that. This also has the advantage that it competely avoids using the verbs "encode" and "decode" and the attendant confusion about which direction they go in. e.g. s = text(b, "base64") makes it obvious that you're going from the binary side to the text side of the base64 conversion. But you aren't always getting unicode text from the decoding of bytes, and you may be encoding bytes to bytes: b2 = bytes(b, "base64") b3 = bytes(b2, "base64") Which direction are we going again?
This is exactly why the current set of codecs are INSANE.
unicode.encode and str.decode should be used only for unicode
codecs. Byte transforms are entirely different semantically and
should be some other method pair.
-bob
- Previous message: [Python-Dev] bytes.from_hex()
- Next message: [Python-Dev] bytes.from_hex()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]