[Python-Dev] (no subject)

François Pinard pinard at iro.umontreal.ca
Fri Jun 18 21:39:09 CEST 2004


[Patrick Stinson]

> if you had a hex string like '0x7c' how would you convert it to an
> int? int(0x7c) works, but not int('0x7c')

This kind of question is better discussed on the `python' list than the
`python-dev' list.

You may try int('0x7c', 16) if you know the base, or int(`0x7c', 0) if
you do not.  The doc-string for `int' does not hint at using 0 as a base
when it has to be guessed, maybe this is an oversight?  The Library
Reference Manual says all about it, however! :-)

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list