[Tutor] More type() puzzlement

Alan Gauld alan.gauld at btinternet.com
Sun Oct 28 01:03:06 CEST 2007


"Dick Moores" <rdm at rcblue.com> wrote 

> n = 10000000000

You start with n as a long.

> print type(n)
> while True:
>     if type(n) == long:
>         n -= 1000000

A long minus an int gives a long:

>>> n = long(42)
>>> n
42L
>>> n - 3
39L

So n never changes into an int even though it is within 
the range of an int.

HTH,

Alan G



More information about the Tutor mailing list