[Python-Dev] bytes.from_hex()
Delaney, Timothy (Tim)
tdelaney at avaya.com
Thu Mar 2 22:48:31 CET 2006
More information about the Python-Dev mailing list
Thu Mar 2 22:48:31 CET 2006
- Previous message: [Python-Dev] bytes.from_hex()
- Next message: [Python-Dev] bytes.from_hex()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Just van Rossum wrote:
> My preference for bytes -> unicode -> bytes API would be this:
>
> u = unicode(b, "utf8") # just like we have now
> b = u.tobytes("utf8") # like u.encode(), but being explicit
> # about the resulting type
+1 - I was going to write exactly the same thing. The `bytes` type
shouldn't know anything about unicode - conversions between bytes and
unicode is entirely the responsibility of the unicode type.
Alternatively, rather than as part of the constructor (though that seems
the obvious place) some people may prefer a classmethod:
unicode.frombytes(cls, encoding)
It gives a nice symmetry.
Tim Delaney
- Previous message: [Python-Dev] bytes.from_hex()
- Next message: [Python-Dev] bytes.from_hex()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list