[Tutor] Exceptions and its error messages

Jonas Melian jonasmg at softhome.net
Wed May 25 14:03:58 CEST 2005


Kent Johnson wrote:
> Jonas Melian wrote:
>> How to know all the exceptions that there are? (i.e. OSError, ImportError)
> 
> Some library modules define their own exceptions such as socket.error so
> the above is not a complete
> list of exceptions defined in the standard distribution, just the ones
> that are built-in.
> 
> And of course third-party modules and your own code can define new
> exceptions so I would say it's
> not possible to know *all* the exceptions that there are.
> 
>> And all error messages of each exception? (i.e. err_o.strerror,
>> err_o.filename)
> 
> I don't understand this part of the question; what is err_o?
> 
I use i.e. with OSError exception the next error messages:
err_o.strerror, err_o.filename

::
try:
    (os.listdir(x))
except OSError, err_o:
    print "Error! %s: %r" % (err_o.strerror, err_o.filename)
::

But how knowing all error messages from some module?
Is there any way of knowing from python interactive line?

::
>>> import [module]
>>> help(exceptions)
::


More information about the Tutor mailing list