How do I get info on an exception ?

Cameron Laird claird at lairds.com
Sat Jul 19 02:19:40 CEST 2003


In article <U2NRa.7475$7O.275 at nwrdny01.gnilink.net>,
Raymond Hettinger <python at rcn.com> wrote:
			.
			.
			.
>You could catch it with:
>
>            except socket.herror, inst:
>                  print inst.args
>
>or more broadly with:
>
>             except socket.error, (errno, string_message):
>                   print code, message
>
>
>> More importantly, where is the answer documented that I should
>> have looked?
>
>The list of possible socket exceptions is in the docs for sockets.
>It also describes the (errno, string) return tuple value of inst.args.
			.
			.
			.
True.

But unsatisfying--at least to me.  I'm curious whether anyone
else sees it the same way.

We're talking here about <URL:
http://www.python.org/doc/lib/module-socket.html >, I assume,
which tells us the socket module has three exception constants
(and what they are), and also such details as that it might be
  except socket.error, (errno, string_message)
but that it also might be simply
  except socket.error, string_message

It's a temptation to go rhetorical at this point, and protest
that we would not believe any other API documented if so little
were written about it, but that we expect this poverty for
exceptions.  Rather than promote a general manifesto, though,
I'll just summarize that neither the manual entry, nor the 
references it provides, give definite knowledge about even the
signature of socket exceptions.  A programmer who wants preci-
sion in regard to exceptions must either experiment, or read
implementation sources--and sometimes both.

So, the answer to the question is the subject line is this:
read the manual, then play with a live system to see what
really happens.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://phaseit.net/claird/home.html




More information about the Python-list mailing list