[Tutor] How can handle exception?

Andy W toodles@yifan.net
Sat, 5 Jan 2002 23:57:53 +0800


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@python.org
> http://mail.python.org/mailman/listinfo/tutor
>