[Python-Dev] Extending hex() and oct() to accept strings
Matthew F. Barnes
mfb at lotusland.dyndns.org
Thu Aug 28 09:20:06 EDT 2003
More information about the Python-Dev mailing list
Thu Aug 28 09:20:06 EDT 2003
- Previous message: [Python-Dev] Extending hex() and oct() to accept strings
- Next message: [Python-Dev] New SIG: email-sig
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> >>> import binascii
>> >>> binascii.hexlify('ABC')
>> '414243'
>> >>>
>
> Or
>
> >>> 'ABC'.encode('hex_codec')
> '414243'
>
> >>> '414243'.decode('hex_codec')
> 'ABC'
The only defense I can think to offer for the hex() and oct() idea is that
I felt like there was something significant about the fact that it was the
first thing I thought to try. It seemed like the "obvious" way to do it.
While both of these solutions are quite readable now that I see them, I'm
not sure that I'd call either of them obvious. However, I can certainly
appreciate the cost of adding bells and whistles to the language,
especially for something that would probably not see much use (as Guido
pointed out).
Thank you both for the tips.
Matthew Barnes
- Previous message: [Python-Dev] Extending hex() and oct() to accept strings
- Next message: [Python-Dev] New SIG: email-sig
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list