[Tutor] How can handle exception?

Andy W toodles at yifan.net
Sat Jan 5 10:57:53 EST 2002


Hi Ladislav

> Hello,
> My program sometimes raise the exception
> 
> socket.error: (10061, 'Connection refused')
> 
> How can I handle this kind of exception?

Enclose it in try, except socket.error. ie.:-

try:
  #do stuff here
except socket.error:
  #handle exception here

Andy

> Thank you for help.
> Ladislav
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 





More information about the Python-list mailing list