Future Warning with Negative Int

Discussion in 'Python' started by brianlum@gmail.com, Apr 14, 2006.

  1. Guest

    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
    , Apr 14, 2006
    #1
    1. Advertising

  2. Peter Otten Guest

    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
    Peter Otten, Apr 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. prem_eda
    Replies:
    5
    Views:
    7,845
    Pieter Hulshoff
    Oct 11, 2004
  2. Schnoffos
    Replies:
    2
    Views:
    1,206
    Martien Verbruggen
    Jun 27, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,625
    Old Wolf
    Jan 20, 2004
  4. arun
    Replies:
    8
    Views:
    449
    Dave Thompson
    Jul 31, 2006
  5. V.Subramanian, India

    no warning for assigning unsigned int to plain int

    V.Subramanian, India, Oct 12, 2011, in forum: C Programming
    Replies:
    5
    Views:
    576
    Keith Thompson
    Oct 12, 2011
Loading...

Share This Page