Exception documentation... RE: newbie class troubles

Mike Fletcher mfletch at tpresence.com
Sun Sep 17 14:51:22 EDT 2000


Having been forced to use VC++ for the past few days (which uses idiotic
numbers instead of error descriptions, but allows you to search for those
error numbers on MSDN and get considerable information), I can see the
argument here.

For experienced python users, the terse syntax of the current error reports
is fine.  For new users or those unfamiliar with a particular library's
errors, an option in the interpreter which prints out theError.__doc__ (or,
more generally, prints the result of a particular method, or if that isn't
present, the doc string, and if that isn't present, use the current
algorithm) when an un-caught exception is raised might be helpful.

Of course, that approach would require that the errors being reported not
use generic TypeErrors, but instead use a subclass of TypeError (or whatever
the particular terse error is) which has documentation for the error
condition.  I'm guessing that would be a royal pain for the implementation
team, but it would make the system more friendly for new users.

It would require a new programming style for most python programmers, as we
would have to get out of the "there's a single error I raise from this
module with all sorts of different string descriptions" mindset and start
creating well-defined hierarchies of exceptions that can be raised.  The
benefits of that should be fairly clear, so I won't go into them. (The
recent changes adding UnboundLocal would seem to suggest we are moving in
this direction anyway.)

Just a thought,
Mike

-----Original Message-----
From: Brett Lempereur [mailto:a.lempereur [remove this|@|remove this]
cableinet.co.uk at python.org]
Sent: Sunday, September 17, 2000 2:31 PM
To: python-list at python.org
Subject: Re: newbie class troubles
...
It's really annoying, because at least when i'm programming in C++ or Vb it
throws up a pile of errors at you with pointers to the solutions, but not in
python, oh no.  The only error i got in python was "TypeError: unbound
method must be called with class instance 1st argument"  seeing as it
doesn't actually happen when the "search.py" module gets compiled, it must
be something to do with the references.
...



More information about the Python-list mailing list