[Tutor] Problem with a class
Andrew Robert
andrew.arobert at gmail.com
Mon May 22 19:31:36 CEST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Everyone,
I am getting an odd traceback when using a class.
The class I am using is
class TriggerMessage:
def __init__(self,data):
"""
Unpacks the passed binary data based on the MQTCM2
format dictated in
the MQ Application Programming Reference
"""
self.data=data
self.structid=None
self.version=None
self.qname=None
self.procname=None
self.trigdata=None
self.appltype=None
self.applid=None
self.envdata=None
self.userdata=None
Self.qmgr=None
def decode(self):
format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s'
size=struct.calcsize(format)
self.structid, self.version, self.qname, self.processname, \
self.triggerdata, self.appltype, self.applid, \
self.envdata, self.userdata, self.qmgr \
= struct.unpack(format,self.data)
When I try to reference the class with the following statement:
test = TriggerMessage.decode(data)
I get the following traceback
Traceback (most recent call last):
File "m:\mq\mq\scripts\receiver.py", line 238, in ?
test = TriggerMessage.decode(data)
TypeError: unbound method decode() must be called by TriggerMessage
instance as first argument (got str instance instead)
Does this make any sense?
The variable data passed to the class is valid and is used elsewhere
correctly.
- --
Thank you,
Andrew Robert
Systems Architect
Information Technologies
MFS Investment Management
Phone: 617-954-5882
E-mail: arobert at mfs.com
Linux User Number: #201204
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32)
iD8DBQFEcfV4Dvn/4H0LjDwRAo9XAJ4viu2SxR50Mgl4DWucJs0+l84r+gCgkcMy
xs+li5sUfKpz1fgAPw5PhuE=
=9IHp
-----END PGP SIGNATURE-----
More information about the Tutor
mailing list