Message70950
> * However, it is *very* obscure. I've been using Python for a year and I
> didn't know about it.
Hmm. There are probably many modules that you haven't used yet.
> * And, it requires importing binascii.
So what? The desire to convert bytes into hex strings is infrequent
enough to leave it out of the realm of a method. Also, Guido has
pronounced that he prefers functions over methods (and in this case,
I agree)
Using functions is more extensible. If you wanted to produce base-85
(say), then you can extend the functionality of bytes by providing a
function that does that, whereas you can't extend the existing bytes
type.
> * And, it results in a bytes object, not a str. That's weird. (Perhaps
> it would be good idea to change the functions in the binascii module to
> output strings instead of bytes? Ostensibly it looks like this module
> hasn't undergone py3kification).
There has been endless debates on this (or, something similar to this),
revolving around the question: "is base-64 text or binary"?
> Would it hurt to have the tohex method of the bytes object to perform
> this task as well?
IMO, yes, it would. It complicates the code, and draws the focus away
from the proper approach to data conversion (namely, functions - not
methods).
> It would be much nicer to use since it's a method of
> the object rather than having to find out about and import and use some
> function.
That's highly debatable.
> Also why have a bytes.fromhex method when you could use binascii.unhexlify?
Good point.
In any case, this is my opion; feel free to discuss this on python-dev.
Very clearly it is too late to add this for 3.0 now. |
|
Date |
User |
Action |
Args |
2008-08-09 18:44:28 | loewis | set | recipients:
+ loewis, mgiuca |
2008-08-09 18:44:27 | loewis | link | issue3532 messages |
2008-08-09 18:44:27 | loewis | create | |
|