+ 5
how can we use raise statement outside except block?
3 Answers
+ 5
you can ALWAYS use raise statement. if you catch it with a try/except block, the program will continue smoothly, if not, it terminates. there are two cases in which terminating is useful;
1- when you actually want to terminate the program. (ie. the user entered invalid input)
2- when you want to end a thread or a subprocess. a raise statement does not terminate the main or "mother" process but does terminate the thread or subprocess which may be what you want
Have a nice day!
+ 4
then the 3rd question is wrong.. I must answer yes to the question "can you use raise statement outside the except block"
- 1
you must build your except block.