[Tutor] built-in hex->int question
Gregor Lingl
glingl@aon.at
Tue, 8 Jan 2002 00:46:17 +0100
My interpreter works consistently:
>>> int('0xaf')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
int('0xaf')
ValueError: invalid literal for int(): 0xaf
>>> float('0xaf')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
float('0xaf')
ValueError: invalid literal for float(): 0xaf
>>> int(0xaf)
175
>>> float(0xaf)
175.0
>>>
Gregor
----- Original Message -----
From: "Lloyd Hugh Allen" <l.h.allen@verizon.net>
To: "Huuuuuu" <mennosimons@gmx.net>
Cc: <tutor@python.org>
Sent: Tuesday, January 08, 2002 12:29 AM
Subject: Re: [Tutor] built-in hex->int question
> You can do long(float('0xaf')), if you want to...don't know if that
> helps.
>
> Huuuuuu wrote:
> >
> > Hi Tutor,
> >
> > Why understands the float() function a string argument but not
> > integer-cast-functions?
> >
> > >>> int('0xaf')
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in ?
> > ValueError: invalid literal for int(): 0xaf
> > >>> long('0xaf')
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in ?
> > ValueError: invalid literal for long(): 0xaf
> > >>> float('0xaf')
> > 175.0
> >
> > Thanks,
> > willi
> >
> > _______________________________________________
> > Tutor maillist - Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>