"Attribute Doesnt Exist" ... but.... it does :-s

Robert Rawlins robert.rawlins at thinkbluemedia.co.uk
Thu Mar 13 12:03:35 EDT 2008


Hi Guys,

Well thanks for the response, I followed your advice and chopped out all the
crap from my class, right down to the bare __init__ and the setter method,
however, the problem continued to persist.

However, Robert mentioned something about unindented lines which got me
thinking so I deleted my tab indents on that method and replaces them with
standard space-bar indents and it appears to have cured the problem.

Usually my Eclipse IDE throws up an error about this but for some reason
decided not too this time around, what a PITA.

Thanks for the ideas guys, I appreciate it.

Robert

-----Original Message-----
From: python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk at python.org]
On Behalf Of Robert Bossy
Sent: 13 March 2008 15:51
To: python-list at python.org
Subject: Re: "Attribute Doesnt Exist" ... but.... it does :-s

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




More information about the Python-list mailing list