reading hex values elegantly from a datagram

Paul Rubin http
Tue Aug 26 19:10:10 CEST 2003


davbucko at yahoo.com (Dave) writes:
> At the moment I am doing crazy things like converting it to a string,
> slicing characters off (ie id = packet[0:2]), adding 0x to the front
> and exec-ing the whole thing to get an integer.

Don't ever exec data from an untrusted source.  Use int(packet[0:2], 16).




More information about the Python-list mailing list