Re: Big-endian binary data to/from Python ints?

2007-12-27 Thread William McBrine
On Wed, 26 Dec 2007 16:50:53 -0800, Dennis Lee Bieber wrote: your code might (I've not actually checked it) be incorrect if ported to another machine. Nope. :-) If the problem is that you have the four bytes as a character string, use the struct module to interpret it as a binary integer

Re: Big-endian binary data to/from Python ints?

2007-12-27 Thread Nikolas Karalis
How do you connect to the socket to receive the 4 byte packet? I'm trying to do that, but then the struct.unpack code above is not working... Nikolas On Dec 27, 2007 1:14 PM, William McBrine [EMAIL PROTECTED] wrote: On Wed, 26 Dec 2007 16:50:53 -0800, Dennis Lee Bieber wrote: your code

Big-endian binary data to/from Python ints?

2007-12-26 Thread William McBrine
Here are a couple of functions that I feel stupid for having written. They work, and they're pretty straightforward; it's just that I feel like I must be missing an easier way to do this... def net_to_int(numstring): Convert a big-endian binary number, in the form of a string of

Re: Big-endian binary data to/from Python ints?

2007-12-26 Thread Matt Nordhoff
William McBrine wrote: Here are a couple of functions that I feel stupid for having written. They work, and they're pretty straightforward; it's just that I feel like I must be missing an easier way to do this... def net_to_int(numstring): Convert a big-endian binary number, in the