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

Fredrik Lundh fredrik at pythonware.com
Thu Nov 7 03:05:52 EST 2002


Tim Peters wrote:

> [Tim]
> >> Write it in a platform-independent way.  If you *intended* this
> >> literal to mean "a 1 bit followed by 31 zero bits", then stick an
> >> L on the end of the literal.
>
> [/F]
> > ...and remove it again when you get to Python 2.5.
>
> You can if you want.  The PEP continues to allow it until Python 3.0.

According to the PEP, Python 2.5 will print warnings whenever you use
long literals.  If the OP doesn't want warnings, he'll have to change his
code for 2.3, and change it back for 2.5.

Looks like the only portable way to use large "unsigned" constants is to
use long("0x80000000")...

</F>





More information about the Python-list mailing list