pylib: better exception message
pylib: allow name specification in an attribute

If not specified, use class name, if it's a base class, fall back to file
name.