[Python-Dev] Attribute error: providing type name

Filip Gruszczyński gruszczy at gmail.com
Sun Nov 30 19:41:55 CET 2008

This is my first message in this list, therefore I would like to say
hello to everyone. I also hope, that I am not breaking any rules or
guidelines for sending proposals.

I would like to ask, if it is possible to provide type name of the
object invoking the exception, when Attribute error is catched. It is
done for functions, like:

AttributeError: 'function' object has no attribute 'getValue'

but for some objects there is only:

AttributeError: connectToBases

This is cool, when you know exactly what type of object cast the
exception. But if there might be many of them, you must do one of two
things: add print statement just before the line with the exception
and check the type or iterate over all classes that might appear them.
Showing the class name would solve this problem and could save a lot
of time.

Filip Gruszczyński

More information about the Python-Dev mailing list