Parsing exceptions the pythonic way
Peter Hansen
peter at engcorp.com
Fri May 30 06:47:18 EDT 2003
Daniel Fackrell wrote:
>
> A friend pointed me at the errno module for handling socket errors. I
> haven't done much socket programming, but the method he was using was to
> perform the action (read/write/etc.) on the socket, and catch the error
> raised by the operation, and then test the actual error code. Something
> like (untested, nearly guaranteed to not work as-is code below):
>
> try:
> mysocket.receive(buffersize)
> except IOError, stuff:
> if stuff == errno.EAGAIN:
Change that to:
if stuff.errno == errno.EAGAIN:
I believe....
-Peter
More information about the Python-list
mailing list