A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-March/062016.html below:

[Python-Dev] bytes.from_hex()

[Python-Dev] bytes.from_hex() [Python-Dev] bytes.from_hex()Delaney, Timothy (Tim) tdelaney at avaya.com
Thu Mar 2 22:48:31 CET 2006
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4