What if an error occurs in the finally statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What if an error occurs in the finally statement

8th Aug 2016, 6:32 PM
Vikrant Banwal
Vikrant Banwal - avatar
3 Answers
0
I think this still holds true if finally throws an error: The documentation says that it's executed "within" the try statement, but it seems like it might be better to say it's executed after the except statement. It has access to all of the variables in the try statement as a consequence of Python's lexical scoping rules, but it's not going to go back to the except clause even if it raises an error. it basically flows back up, finally throws error with traceback to try. code in the except clause will not be executed.
9th Aug 2016, 1:47 AM
Izz
Izz - avatar
0
got it thanxx
9th Aug 2016, 2:36 AM
Vikrant Banwal
Vikrant Banwal - avatar
0
fix error
9th Aug 2016, 10:32 AM
Sam Sharp
Sam Sharp - avatar