A funnily inconsistent behavior of int and float

Mark Dickinson dickinsm at gmail.com
Mon Apr 7 15:55:52 EDT 2008


On Apr 7, 3:53 pm, Mark Dickinson <dicki... at gmail.com> wrote:
> The only base 0 versus base 10 difference I could find was the
> following:
>
> >>> int('033', 0)
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ValueError: invalid literal for int() with base 0: '033'
> [38720 refs]>>> int('033')
>
> 33
>
> Mark

And also things like:

>>> int('0x33')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '0x33'
[38719 refs]
>>> int('0x33', 0)
51
[38719 refs]

Mark



More information about the Python-list mailing list