Forgot to send to list... On Mon, Aug 25, 2008 at 7:45 PM, Py Hex <[EMAIL PROTECTED]> wrote:
> When I run this: > > >>> type(hex(12)) > <type 'str'> > > I get a string type back, i.e, '0xC' not 0xC > > On the other hand, if I use 0x with data, Python understands it is hex data > and not a string value. > > >>> e = 0xCD > >>> type(e) > <type 'int'> You missed trying something: >>> e = 0xCD >>> e 205 >>> type(e) <type 'int'> It doesn't store the value as hex data, it stores it as an integer. I'm really not sure about anything else (i.e. converting the value to an integer - I've tried and int(e) doesn't work when it's a hex string) though. HTH, Wayne p.s. After a quick Google, I discovered how to convert the other way: int('0xCD', 0) will give you the integer value of your string (if it's hex. If you're doing octal you'll want int(myOctal, 8) ) -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor