Class probkem - getting msg that self not defined
wes weston
oweston at earthlink.net
Mon May 22 15:17:19 EDT 2006
Andrew Robert wrote:
> wes weston wrote:
>> 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)
>>>
> <snip>
>
> I guess I was barking up the wrong tree on that one.
>
> How would I go about getting the required values out of the class?
>
> Return self?
You can refer to the variables inside the class as test.version;
for example - as they are not protected. Or, you could add access
methods in the class like def GetVersion(self): return self.version
If you want to protect version, call it self.__version which mangles
the name from outside.
wes
More information about the Python-list
mailing list