Python 2.3: int() ?
Michael Hudson
mwh at python.net
Fri Jan 17 11:36:20 EST 2003
Carsten Gaebler <news at snakefarm.org> writes:
> Hi there,
>
> I just read the 2.3 'highlights' page on python org, and I'm a bit
> confused: it says '# int() - this can now return a long when
> converting a string with many digits, rather than raising
> OverflowError.'
>
> What does 'can' mean here?
It means it sometimes returns a long, sometimes an int.
>>> type(int("1" + "0"*3))
<type 'int'>
>>> type(int("1" + "0"*30))
<type 'long'>
> Can I switch between returning a long or raising an exception?
No. At least, I'm pretty sure not.
Cheers,
M.
--
Its unmanageable complexity has spawned more fear-preventing tools
than any other language, but the solution _should_ have been to
create and use a language that does not overload the whole goddamn
human brain with irrelevant details. -- Erik Naggum, comp.lang.lisp
More information about the Python-list
mailing list