Hey everyone,
Maybe you can see something I don't. I need to convert a working piece of perl code to python. The perl code is: sub ParseTrig { # unpack the ibm struct that triggers messages. my $struct = shift; my %data; @data{qw/StructID Version QName ProcessName TriggerData ApplType ApplId EnvData UserData QMgrName/} = unpack("A4A4A48A48A64A4A256A128A128A48", $struct); return undef unless $data{StructID} eq 'TMC'; return \%data; Taking away the fact that it is a function, the base code sets a 732 element structure with the ascii pattern derived above. I wrote a simple test script that accepts the command argument at position 1. #!C:\Python24\python import sys, string, struct # From the language declarations in manual, the following format was derived format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s' size=struct.calcsize(format) # Extract list item out for convenience/readability data=sys.argv[1] # Calculated size of the struct format is 732 # Length of data string is 732 print len(data) print size d1,d2=struct.unpack(format,data) print d1 sys.exit(0) When I run it, it says there are too many values to unpack. Traceback ( most recent call last) File "m:\mq\mq\scripts\format.py", line 32, in ? d1, d2 = struct.unpack(format,data) ValueError: too many values to unpack Error starting triggered application I checked the manual on the structure used to pack the code and it appears correct. # # MQTMC2 Language declarations as defined chapt 22 of programmers ref # http://publibfp.boulder.ibm.com/epubs/pdf/csqzak09.pdf # # CHAR4 Struct ID # CHAR4 Version # CHAR48 QName # CHAR48 ProcessName # CHAR64 TriggerData # CHAR4 ApplType # CHAR256 ApplID # CHAR128 EnvData # CHAR128 UserData # CHAR48 QMgrName Any help you can provide on this would be greatly appreciated. -- http://mail.python.org/mailman/listinfo/python-list