ConnectionError handling problem

Jon Ribbens jon+usenet at
Sun Sep 20 14:45:47 CEST 2015

On 2015-09-19, Mark Lawrence <breamoreboy at> wrote:
> On 19/09/2015 07:13, shiva upreti wrote:
>> 		try:
>>, data=query_args)
>> 		except:
>> 			print "Connection error"
> Never use a bare except in Python, always handle the bare minimum number 
> of exceptions that you need to, in this case your ConnectionError.

While I entirely agree with the principle of being specific in what
exceptions you are catching (with the absolute maximum being
'Exception'), it is often not obvious which ones you need to specify.
The code above probably actually needs to catch EnvironmentError if
it is intended to intercept all network problems.

More information about the Python-list mailing list