Understanding (and getting rid) of optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a

hofer blabla at dungeon.de
Fri Sep 26 16:53:02 CEST 2008


Hi,

I get following warning with a python script:


optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will
return a signed string in Python 2.4 and up


my code:
from optparse import OptionParser

if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option('-G','--green',action= 'store_const', const=
'#00FF00' ,  dest='color',
                       default='#808080',
                    help='life is so green')
    parser.add_option('-R','--red',action= 'store_const', const =
'#FF0000' , dest='color',
                    help='I just see red')
    # add more elaborated command line parsing and help text here
    (options,argv) = parser.parse_args()
    print 'options',options

I assume python wants to tell me that newer version will behave
differently for numeric arguments

What I wonder is: Why do I get the warning if my code doesn't try to
parse any numbers?

Is there any way to get rid of the warning without having to change
the python version?
(I noticed, the warning disappears if I remove the line printing
options)





thanks for any explanations. suggestions


H



More information about the Python-list mailing list