Hey Bruno,
Although I have not tested it, this appears to be it exactly. Some confusion though. <snip </snip> > import struct > > class TriggerMessage(object): > def __init__(self,data): > """ > Unpacks the passed binary data based on the > MQTCM2 format dictated in > the MQ Application Programming Reference > """ I am okay up to here :). After that, well.. What does the _ before the variables mean? Why are you defining _format and _data here? I would have thought it belongs in the decode section. I think it is very slick but I would like to try and understand your approach. Also, why assert in calculating the struct size? Very cool how you did this. > self._format = '4s 4s 48s 48s 64s 4s 256s 128s 128s 48s' > self._data = data > > (self.version, > self.qname, > self.processname, > self.triggerdata, > self.appltype, > self.applid, > self.envdata, > self.userdata, > self.qmgr) = self._decode() > > def _decode(self): > assert len(self._data) == struct.calcsize(self._format) > return struct.unpack(self._format, self._data) > > # test code > # data = ??? > test=TriggerMessage(data) > var = test.qname -- http://mail.python.org/mailman/listinfo/python-list