Attribute error

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Jan 18 18:31:47 EST 2015


Mahendra Prajapati wrote:

> Hello,
> I'm facing this problem with python class, while practising the python
> programming language.It creates an attribute error. I use windows 7 OS. i
> don't why.I just need to know why it gives such an error.please let me
> know. Regards

An attribute error is a bug in your code. Fix the bug.

It might be a spelling error:

s = "Hello World!"
s.uper()  # Oops, I meant "upper"

or it might be that you have the wrong object:

alist = [2, 4, 1]
alist = alist.sort()  # Oops, replaces alist with None
alist.index(2)  # None has no index method.

Either way, it is a bug in your code that needs to be fixed.




-- 
Steven




More information about the Python-list mailing list