Re: Python less error-prone than Java
- From: aleax@xxxxxxx (Alex Martelli)
- Date: Sat, 3 Jun 2006 17:07:48 -0700
Simon Percivall <percivall@xxxxxxxxx> wrote:
...
with static typing. The equivalent in Python would have been if an
overflow exception was raised when the int got too big. It might have
been that way, typing or no typing.
Indeed, it _used_ to be that way --
<http://docs.python.org/lib/module-exceptions.html> STILL says...:
exception OverflowError
Raised when the result of an arithmetic operation is too large to be
represented. This cannot occur for long integers (which would rather
raise MemoryError than give up). Because of the lack of standardization
of floating point exception handling in C, most floating point
operations also aren't checked. For plain integers, all operations that
can overflow are checked except left shift, where typical applications
prefer to drop bits than raise an exception.
Actually, the docs are obsolete on this point, and an int becomes a long
when that's necessary:
2147483648Lsys.maxint+1
but, this operation _would_ have raised OverflowError in old-enough
versions of Python (not sure exactly when the switch happened...).
Alex
.
- References:
- Python less error-prone than Java
- From: Christoph Zwerschke
- Re: Python less error-prone than Java
- From: Simon Percivall
- Python less error-prone than Java
- Prev by Date: Re: Using print instead of file.write(str)
- Next by Date: Re: ideas for programs?
- Previous by thread: Re: Python less error-prone than Java
- Next by thread: Re: Python less error-prone than Java
- Index(es):
Relevant Pages
|
Loading