[Python-Dev] bytes.from_hex()
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 (to_base64, from_base64, 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.b2a_base64
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