import warnings
warnings.filterwarnings('ignore')
a = 0xffffffff
Thanks,
Rob
The warning is issued during the compilation, not the execution of your
script. Therefore the attempt to turn off the warning, although before the
offensive statement, comes too late.
<offensive.py>
a = 0xffffffff
</offensive.py>
One workaround is to precompile offensive.py (By the way is there a flag to
do this that I've overlooked?):
$ python -c"import offensive"
offensive.py:1: FutureWarning: hex/oct constants > sys.maxint will return
positive values in Python 2.4 and up
a = 0xffffffff
and then invoke offensive.pyc:
$ python offensive.pyc
All quiet :-)
The other option would be to reorganize your script to the same effect.
$ rm offensive.pyc
$ python driver.py
$
Where driver looks like so:
<driver.py>
import warnings
warnings.filterwarnings('ignore') # should probably be more specific
import offensive
</driver>
Of course you could omit the first two lines when you can live with a
warning the first time you run driver.py after every change of
offensive.py.
Peter