[IronPython] int() and long() incompatibility
Floris van Nee
floris.vannee at gmail.com
Mon Oct 9 17:13:31 CEST 2006
Yeh, I thought of that as well (a few days ago actually ;)), but that
doesn't work in CPython as well. To my knowledge the 0x prefix is only used
to indicate it's a hexadecimal number, so I too thought why I had to give 16
as an argument as well. But that's not really in the scope of this list, as
it's not a compatibility problem with CPython. It would be nice if they'd
change that in some next release of Python though. :)
Floris
On 10/9/06, J. Merrill <jvm_cop at spamcop.net> wrote:
>
> I'm wondering if int('0x20') (without the explicit radix value 16)
> should work. Doesn't the '0x' prefix mean that it's a hex number, radix 16,
> unambiguously?
>
> OTOH, I would not expect int('033') to interpret the value as if the
> radix is 8, because the "leading 0 means octal" convention is both very old
> and a really really really bad idea! But 0x prefix doesn't mean anything
> else -- does it?
>
> I'm waiting for the Pascal programmers to say that int('$20') should
> work, returning 32, because $ is the Pascal-language equivalent of '0x' --
> but it shouldn't. To someone entering data into a computer program, '$20'
> is not a value in hex, it's an amount of money!
>
> At 10:26 AM 10/9/2006, Floris van Nee wrote
>
> I just checked it myself to see what works and what doesn't. You're right
> that it doesn't work when putting '0x' in front of it. However, when I just
> do int('20', 16) it returns 32, which is correct.
>
> It is a bit weird though, that int(hex(20), 16) returns an error and I
> think that should be fixed. [snip]
>
> On 10/9/06, *Sanghyeon Seo* <sanxiyn at gmail.com> wrote:
> >>> int('0x20', 16)
> ValueError: invalid integer number literal
>
> Same for long. Python library reference isn't clear on this point, but
> my reading doesn't support this misfeature since one can use radix 0
> to the same effect. Anyway, there are codes out there depending on
> this. :(
>
> --
> Seo Sanghyeon
>
>
>
> J. Merrill / Analytical Software Corp
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20061009/2ef8c2d7/attachment.html>
More information about the Ironpython-users
mailing list