By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,995 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,995 IT Pros & Developers. It's quick & easy.

Using try and catch

100+
P: 440
Hi,

Is ussage of try and catch block will slow down the application execution process,even it will help the application from crashing or giving error messages etc?.

-PSB
Apr 30 '07 #1
Share this Question
Share on Google+
1 Reply


bartonc
Expert 5K+
P: 6,596
Hi,

Is ussage of try and catch block will slow down the application execution process,even it will help the application from crashing or giving error messages etc?.

-PSB
The trick is deciding what to "wrap" in the try block: Inside a loop that may throw only one type of error would be a poor decision. Outside of loops, there is no down-side to catching errors. For example:
Expand|Select|Wrap|Line Numbers
  1. try:
  2.     while True:
  3.         aValue = aList[anIndex]
  4.         # ...
  5. except IndexError:
  6.     print 'got an index error'
will only do good things for you app.
Apr 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.