Dealing with hex

Derrick 'dman' Hudson dman at dman13.dyndns.org
Wed Dec 10 18:04:01 EST 2003


On Wed, 10 Dec 2003 03:49:16 GMT, Matt Gerrans wrote:
> Is there an ideal approach to dealing with the FutureWarning about getting
> the hex value of a negative int?    I'm using zlib.crc32() which can return
> a negative 32-bit int value, so for example print '%x' % zlib.crc32(
> buffer ) generates the FutureWarning.    I know I could jump through hoops
> to coerce the int into a long that will have the same CRC, but is there some
> particular recomendation for this (I looked at PEP 237, but there wasn't a
> suggestion).

Hoops?  For example :
    print "%x" % long( zlib.crc32( buffer ) )

That seems simple enough to me.

-- 
If your life is a hard drive,
Christ can be your backup.
 
www: http://dman13.dyndns.org/~dman/            jabber: dman at dman13.dyndns.org




More information about the Python-list mailing list