int/long unification hides bugs

Cliff Wells clifford.wells at comcast.net
Mon Oct 25 23:15:02 EDT 2004


On Mon, 2004-10-25 at 21:48 -0500, Jeff Epler wrote:
> Here's a bug that passes silently because ints are not limited in range
> from 1 to 100:
>     ...
> 
> OK, just joking.  I couldn't think of one.

Here's one:

# count how many ferrets I have
ferrets = 0
while 1:
    try:
        ferrets += 1
    except:
        break
print ferrets

As you can clearly see, the answer should have been 3, but due to Python
silently allowing numbers larger than 3 the program gets stuck in an
apparently interminable loop, requiring me to reboot Microsoft Bob.

-- 
Cliff Wells <clifford.wells at comcast.net>




More information about the Python-list mailing list