Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Future Warning with Negative Int

Reply
Thread Tools

Future Warning with Negative Int

 
 
brianlum@gmail.com
Guest
Posts: n/a
 
      04-14-2006
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:
>>> print "%X" % -1

__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

 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      04-14-2006
wrote:

> If I try to print a negative integer as a hexadecimal, I get the
> following error:


>>>> print "%X" % -1

> __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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
no warning for assigning unsigned int to plain int V.Subramanian, India C Programming 5 10-12-2011 07:41 PM
Difference between int i, j; and int i; int j; arun C Programming 8 07-31-2006 05:11 AM
Negative setup and Negative hold prem_eda VHDL 5 10-11-2004 12:14 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57