hex(-5) => Futurewarning: ugh, can't we have a better hex than '-'[:n<0]+hex(abs(n)) ??
oinkfreddie at oinkshlick.oinknet
Mon Aug 18 05:06:16 CEST 2003
"Michael Peuser" <mpeuser at web.de> wrote in news:bhot6f$65j$07$1 at news.t-
> "Bengt Richter" <bokr at oz.net> schrieb im Newsbeitrag
> news:bhomem$jg8$0 at 220.127.116.11...
>> >>> hex(-5)
>> __main__:1: FutureWarning: hex()/oct() of negative int will return a
> signed string in Python 2.4 and up '0xfffffffb'
> There is a thread from this morning ("bitwise not ...") - this should be an
> excellent contribution!
> I have no mercy with someone writing hex(-5)
> Michael P
What about crazy people like myself? If you generate a crc32 value with zib,
you occasionally get a negative number returned. If you try to convert that
to hex (to test against a stored CRC32 value), it spits out a FutureWarning
at me. So you end up with silly things like this in your code:
# Disable FutureWarning, since it whinges about us making bad hex values :(
Remove the oinks!
More information about the Python-list