hex/oct constants > sys.maxint will return positive values in Python 2.4 and up

Tim Peters tim.one at comcast.net
Thu Nov 7 13:42:13 EST 2002


[Bengt Richter
> How about
>
>     BIT31 = 1<<31
>
> and then use BIT31 wherever?

That's currently platform-dependent in exactly the same way as 0x80000000,
will also become platform-independent in Python 2.4, and also generates a
warning in 2.3:

>>> 1 << 31
__main__:1: FutureWarning: x<<y losing bits or changing sign will
            return a long in Python 2.4 and up
-2147483648
>>>





More information about the Python-list mailing list