Robert Rawlins wrote: > > Hello Guys, > > I’ve got an awfully aggravating problem which is causing some > substantial hair loss this afternoon J I want to get your ideas on > this. I am trying to invoke a particular method in one of my classes, > and I’m getting a runtime error which is telling me the attribute does > not exist. > > I’m calling the method from within __init__ yet it still seems to > think it doesn’t exist. > > Code: > > # Define the RemoteDevice class. > > class *remote_device*: > > # I'm the class constructor method. > > def *__init__*(/self/, message_list=/""/): > > /self/.set_pending_list(message_list) > > def *set_pending_list*(/self/, pending_list): > > # Set the message list property. > > /self/.pending_list = message_list > > And the error message which I receive during the instantiation of the > class: > > File: “/path/to/my/files/remote_device.py", line 22, in __init__ > > self.set_pending_list(message_list) > > AttributeError: remote_device instance has no attribute 'set_pending_list' > > Does anyone have the slightest idea why this might be happening? I can > see that the code DOES have that method in it, I also know that I > don’t get any compile time errors so that should be fine. I know it > mentions line 22 in the error, but I’ve chopped out a load of non > relevant code for the sake of posting here. > Hi, I don't get this error if I run your code. Maybe the irrelevant code causes the error: my guess is that there's a parenthesis mismatch or an undeindented line.
Btw, calls to set_pending_list will fail since the name "message_list" is not defined in its scope. Please follow Chris Mellon's advice. Cheers, RB -- http://mail.python.org/mailman/listinfo/python-list