[Python-Dev] bytes.from_hex() (original) (raw)

Terry Reedy tjreedy at udel.edu
Sat Feb 18 23:48:10 CET 2006


"Josiah Carlson" <jcarlson at uci.edu> wrote in message news:20060218005534.5FA8.JCARLSON at uci.edu...

Again, the problem is ambiguity; what does bytes.recode(something) mean? Are we encoding to something, or are we decoding from something? Are we going to need to embed the direction in the encoding/decoding name (tobase64, frombase64, etc.)?

To me, that seems simple and clear. b.recode('from_base64') obviously requires that b meet the restrictions of base64. Similarly for 'from_hex'.

That doesn't any better than binascii.b2abase64

I think 'from_base64' is much better. I think there are now 4 string-to-string transform modules that do similar things. Not optimal to me.

What about .reencode and .redecode? It seems as though the 're' added as a prefix to .encode and .decode makes it clearer that you get the same type back as you put in, and it is also unambiguous to direction.

To me, the 're' prefix is awkward, confusing, and misleading.

Terry J. Reedy



More information about the Python-Dev mailing list