+ 4

what is the use of exception in progaraming???

24th Sep 2016, 3:03 PM
Abdul Azeez
Abdul Azeez - avatar
8 Réponses
+ 11
you can use exception to by pass an error without stoping the running program
24th Sep 2016, 5:03 PM
julio velarde
julio velarde - avatar
+ 5
The Exceptions are the way to deal with errors in Python. When you want to be a good programmer in Python, you REALLY have to know how to use them, as they are at the foundation of the language.
25th Sep 2016, 11:25 AM
Amaras A
Amaras A - avatar
+ 3
If proper used, exceptions makes your code cleaner. Instead of doing checks everywhere, you can assume things are right and if an error arises you caught it using a exception. For example you do not need to check array indexes or the denominator of a division, if theses errors occurs treat them them with exceptions. Of course some checks are still needed, but they will related to your problem. Even on this case exceptions can simplify your code because you can raise your own exceptions.
3rd Nov 2016, 11:41 PM
Luis Eduardo Bravo de Moura
Luis Eduardo Bravo de Moura - avatar
+ 2
Just because you ask for a number doesn't mean everyone will provide one. Programs crash (or worse) when they don't sanitize inputs...or fail to anticipate exceptional, interrupting events.
26th Sep 2016, 5:43 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
I will just give one example where it is useful: when you try to access a temporary file, either you check whether every single condition on it is expected and Behold! the file is gone... Or you can just try to access it and see if there's a problem later.
9th Oct 2016, 9:47 AM
Amaras A
Amaras A - avatar
+ 1
It allows you to decouple the actions and the handling of errors that might arise during those actions. Enabling you to concentrate error handling in one place instead of peppering your code with it. Also, sometimes the code that knows what to do about an error is a few levels above the actual function that caused it. Without exceptions, all the functions at intermediary levels would have to know all the error types and explicitly pass them back to callers.
4th Nov 2016, 3:11 AM
Rei Dalaran
Rei Dalaran - avatar
+ 1
exception is use to indicate what's errors in our program and validation of data types.
7th Jan 2017, 7:30 AM
Ravi Verma
Ravi Verma - avatar
+ 1
It is particularly used for raising errors when input by the user is not right
3rd Feb 2017, 3:50 AM
Himanshu