In article <[EMAIL PROTECTED]>, Rene Pijlman <[EMAIL PROTECTED]> wrote:
> Roy Smith: > >In theory, all exceptions which represent problems with the external > >environment (rather than programming mistakes) should derive from > >Exception, but not from StandardError. > > Are you sure? > > """ > The class hierarchy for built-in exceptions is: > > Exception > +-- StandardError > | +-- KeyboardInterrupt > | +-- ImportError > | +-- EnvironmentError > | | +-- IOError > """ > http://www.python.org/doc/current/lib/module-exceptions.html Hmmm, OK, I missed EnvironmentError. So, what you need to do is: try: whatever() except EnvironmentError: ... except StandardError: ... except Exception: ... or something like that. I do agree with you that there is some value in Java's "must catch or re-export all exceptions" semantics, and this would be one of those places where it would be useful. In general, however, I've always found it to be a major pain in the butt, to the point where I sometimes just punt and declare all my methods to "throw Exception" (or whatever the correct syntax is). Not to mention that with a dynamic language like Python, it's probably impossible to implement. I think the real problem here is that the on-line docs are incomplete because they don't list all the exceptions that this module can raise. The solution to that is to open a bug on sourceforge against the docs. -- http://mail.python.org/mailman/listinfo/python-list