Future Warning with Negative Int

B

brianlum

Hi,

If I try to print a negative integer as a hexadecimal, I get the
following error:
FutureWarning: %u/%o/%x/%X of negative int will return a signed string
in Python 2.4 and up

For example:__main__:1: FutureWarning: %u/%o/%x/%X of negative int will return a
signed string in Python 2.4 and up
FFFFFFFF

Does that mean that in the future it will say -1 or -FFFFFFFF? Also,
how do I suppress this warning?

Thanks,
Brian
 
P

Peter Otten

If I try to print a negative integer as a hexadecimal, I get the
following error:
__main__:1: FutureWarning: %u/%o/%x/%X of negative int will return a
signed string in Python 2.4 and up
FFFFFFFF

Does that mean that in the future it will say -1 or -FFFFFFFF?

The future is now:

$ python2.4 -c 'print "%X" % -1'
-1
Also, how do I suppress this warning?

With the -W option:

$ python2.3 -W ignore -c 'print "%X" % -1'
FFFFFFFF

or warnings.filterwarnings('ignore').

http://docs.python.org/lib/warning-functions.html

has more on the subject.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top