[Python-Dev] Negative long literals (was Re: Does Python need a '>>>' operator?)

Guido van Rossum guido@python.org
Mon, 10 Jun 2002 09:28:42 -0400


>   I like the idea but I'm not sure that still solves the down casting
> problem. Say I do some bit ops on a long type and want to get it
> into an int size (for whatever reason and there are several), I need
> somehow to tell python that it is not an overflow when I'm int()ing
> the number. Perhaps int could take a second hidden argument. Be
> able to do a:
> 
>   int(big_num, signed=1)
> 
>   which is pretty clear.

I haven't been following the thread on c.l.py.  What problem do you
think this is trying to solve?

Anyway, if you want to get an int back (which should be pretty rare in
2.2 and up since ints and longs are *almost* completely
interchangeable) you should be able to say something like

  x & 0x7fffffff

--Guido van Rossum (home page: http://www.python.org/~guido/)