What if I will close the file without "try" and "finally" statements? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What if I will close the file without "try" and "finally" statements?

25th Jul 2016, 7:41 AM
St. R.
St. R. - avatar
4 Answers
+ 2
nothing happens my friend... it is just precaution. supposing you don't do anything weird on it you don't need to use finally and try
26th Jul 2016, 1:31 AM
André Ferreira
André Ferreira - avatar
0
"Try"..."Finally" is a good way to handle possible exceptions.
28th Jul 2016, 8:38 PM
Matt Ferrie
Matt Ferrie - avatar
0
if an exception happens and say is handled higher up, the finally clause ensures the code runs regardless. basic example of how finally works: def foo(): try: return 0 finally: return -1
3rd Aug 2016, 2:32 AM
tom
0
But WHY?U CAN SIMPLY USE WITH ...AS MODEL
31st Aug 2016, 4:59 AM
Leshark
Leshark - avatar