under phython
hex(-1)
'-0x1'
but i want a 2.3 style output like
hex(-1)
'0xffffffff'
what should i do?
The following:
>>> def hex(x): ... return "0x%x" % ((x < 0) * 0x100000000 + x)
should return the same output on 2.3/2.4
If you are concerned about non-32 bit systems, then you could write more conservatively:
>>> import sys
>>> WORD = (sys.maxint+1)*2
>>> def hex(x):
... return "0x%x" % ((x < 0) * WORD + x)
...
HTH Michael
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32