What does AttributeError mean?

Huaiyu Zhu hzhu at yahoo.com
Fri Sep 22 04:02:47 EDT 2000


On Thu, 21 Sep 2000 19:10:34 +0100, Dale Strickland-Clark
<dale at out-think.NOSPAMco.uk> wrote: 

>>>> srch.SQLString()
>Traceback (innermost last):
>  File "<interactive input>", line 1, in ?
>AttributeError: SQLString

In 2.0, the error message is more understandable, like

>>> class A: pass
... 
>>> a=A(); a.b()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  AttributeError: 'A' instance has no attribute 'b'

But it is slightly missleading because attributes could be set in instances
instead of class.  So why not?

  AttributeError: <__main__.A instance at 0x8270294> has no attribute 'b'

Better still, if the actual calling name is still available in byte code,
may be even

  AttributeError: instance a of class __main__.A has no attribute 'b'


Huaiyu



More information about the Python-list mailing list