Before I was bitten by the difference below, I think these two ways are
the same.
However, they are not.
Is there any geek who can tell me if this is a bug?
(some weird '\x00\x00' was inserted between '0123456789abcd' and 6 )
>>struct.pack('3I14sI',1,19960101,14,'0123456789ab cd',6)
'\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456 789abcd\x00\x00\x06\x00\x00\x00'
>>struct.pack('3I14s',1,19960101,14,'0123456789abc d')+struct.pack('I',6)
'\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456 789abcd\x06\x00\x00\x00' 2 1629
I got it, alignment issue...
>struct.pack('!3I14sI',1,19960101,14,'0123456789ab cd',6)
'\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456 789abcd\x06\x00\x00\x00'
>struct.pack('!3I14s',1,19960101,14,'0123456789abc d')+struct.pack('!I',6)
'\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456 789abcd\x06\x00\x00\x00'
rong.x...@gmail.com wrote:
Before I was bitten by the difference below, I think these two ways are
the same.
However, they are not.
Is there any geek who can tell me if this is a bug?
(some weird '\x00\x00' was inserted between '0123456789abcd' and 6 )
>struct.pack('3I14sI',1,19960101,14,'0123456789abc d',6)
'\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456 789abcd\x00\x00\x06\x00\x00\x00'
>struct.pack('3I14s',1,19960101,14,'0123456789abcd ')+struct.pack('I',6)
'\x01\x00\x00\x00%\x910\x01\x0e\x00\x00\x000123456 789abcd\x06\x00\x00\x00'
On 2006-08-25, ro*******@gmail.com <ro*******@gmail.comwrote:
Before I was bitten by the difference below, I think these two
ways are the same. However, they are not.
As is explained here: http://www.python.org/doc/current/li...le-struct.html
Is there any geek who can tell me if this is a bug?
Yes there is.
No it isn't a bug.
It's all explained in the manual: If you don't specify a byte
order, native byte order an alignment are assumed.
--
Grant Edwards grante Yow! NEWARK has been
at REZONED!! DES MOINES has
visi.com been REZONED!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gordon Scott |
last post by:
Hi All,
I've got a problem I'm seeing when trying to use the struct module to send
data to a different machine.
Actually I'm making a condensed file that gets transferred to and read on a
BREW...
|
by: Angelo Secchi |
last post by:
I'm trying to use the unpack method in the struct module to parse a
binary file without success. I have a binary file with records that
include many fields for a total length of 1970. Few days ago...
|
by: James S |
last post by:
Hi,
Basically I've been fighting with this code for a few days now and
can't seem to work around this problem. Included is the output, the
program I use to get this error and the source code for...
|
by: Josiah Carlson |
last post by:
Good day everyone,
I have produced a patch against the latest CVS to add support for two
new formatting characters in the struct module. It is currently an RFE,
which I include a link to at the...
|
by: chris |
last post by:
This is my first attempt at undertaking a C extension module. I want
to wrap an existing C library so I can call the functions from Python.
There are only two functions I'm interested in calling. ...
|
by: ahn1 |
last post by:
Hi,
I have a user who complained about how "struct" module computes C
struct data size on Itanium2 based 64-bit machine.
His first reproducer was
--------------------------------------...
|
by: Jérôme Le Bougeant |
last post by:
Hello (and sorry for my English),
I downloaded the VideoCapture module on the
http://videocapture.sourceforge.net/ site. I tested it with a webcam and
that functions.
Now I want to...
|
by: Keith |
last post by:
Hello,
I am trying to create exectuables on inux using "pyinstaller". I am
using pyinstaller-1.3, RHEL 4.4, Python 2.5.
The executables fail to run. The problem returned is pertaining to...
|
by: rjcarr |
last post by:
Sorry if this is a completely newbie question ...
I was trying to get information about the logging.handlers module, so
I imported logging, and tried dir(logging.handlers), but got:
...
|
by: hnshashi |
last post by:
I have writtem kernel(2.4) module to commu. with user space appl. using netlink socket. I am getting compilation error.
kernel module:->
#include <linux/skbuff.h>
#include<linux/module.h>
...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |