A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/068228.html below:

Python version of binascii.b2a_hex (binary to hex conversion)?

Python version of binascii.b2a_hex (binary to hex conversion)?Barry A. Warsaw barry at digicool.com
Fri Apr 27 18:16:36 EDT 2001
>>>>> "GG" == Graham Guttocks <graham_guttocks at yahoo.co.nz> writes:

    GG> Greetings Barry,

    GG> I don't mean to look a gift horse in the mouth so to speak,
    GG> but is there a way to unhexlify using all builtins such as
    GG> what I've done with hexlify here?

    |     def hexlify(b):
    |         return "%02x"*len(b) % tuple(map(ord, b))

Well, depends on how you define `builtins' :)  Do you mean functions
in the builtin module, or C builtin functions?  Or are you looking for
a convenient one-liner?

Essentially the unhexlify I posted uses only C builtin functions,
e.g. [].append, strop.atoi, range, len, chr, strop.join.  I don't
remember if anybody came up with a nice one-liner when the thread was
debated eons ago.

Cheers,
-Barry


More information about the Python-list 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