More informative AttributeError message?

Mark Hammond MarkH at ActiveState.com
Wed Aug 16 21:54:33 EDT 2000


> I would suggest that the traceback of AttributeError also indicate
the class
> of the object.
>
> For example, an exception traceback like
>   File "...", line 135, in get_data
>     col = col.trans(tr)
>     AttributeError: trans

Guido's time machine is at it again!  In 1.6 and later, it has been
improved:

PythonWin 2.0b1 (#0, Aug 16 2000, 12:01:03) [MSC 32 bit (Intel)] on
win32.
Portions Copyright 1994-2000 Mark Hammond (MarkH at ActiveState.com) -
see 'Help/About PythonWin' for further copyright information.
>>> class A:
...  pass
...
>>> a=A()
>>> a.foo
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
AttributeError: 'A' instance has no attribute 'foo'
>>>

Mark.






More information about the Python-list mailing list