PyCharm warns about this code, stating that the last return is not available:
def foo(): with open(...): return 1 return 0
I expect the second refund to be completed if open()failed. Who is right?
open()
PyCharm is right. If open()not satisfied, an exception occurs and is not reached return.
return
with , . , with , __exit__ __enter__. , , . with .
with
__exit__
__enter__
Source: https://habr.com/ru/post/1664528/More articles:Android Things and Bluetooth - bluetoothHow to convert a 3-level dictionary to the desired format? - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1664525/clipping-borders-to-subviews&usg=ALkJrhgjdEZ6LAWKkT3ZdCIXG9wwarDMrQFortran-derived constructor type defined using function C (II) - cUser registration in development via API - jsonFortran type constructor defined with C - cDefinition of FK names in many ways - c #start and stop control does not work youtube - javascriptThrobbing effect on an icon in HTML5 with CSS - htmlhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1664533/listjs-finds-the-element-but-still-keeps-others-too&usg=ALkJrhgahPZWBh9u05i5Ci95YbhIgyp9SgAll Articles