Class probkem - getting msg that self not defined
wes weston
oweston at earthlink.net
Mon May 22 14:45:38 EDT 2006
Andrew Robert wrote:
> Hi Everyone,
>
> I am having a problem with a class and hope you can help.
>
> When I try to use the class listed below, I get the statement that self
> is not defined.
>
> test=TriggerMessage(data)
self is not known here; only inside the class.
> var = test.decode(self.qname)
>
> I would have thought that self would have carried forward when I grabbed
> an instance of TriggerMessage.
>
> Any ideas on this?
>
>
>
> The class in question is:
>
>
> class TriggerMessage(object):
>
> 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):
> import struct
> format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s'
> size=struct.calcsize(format)
> self.data=data
> 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)
More information about the Python-list
mailing list