python try:except:finally
问题 # Open new file to write file = None try: file = open(filePath, 'w') except IOError: msg = ("Unable to create file on disk.") file.close() return finally: file.write("Hello World!") file.close() The above code is ripped from a function. One of the user's system is reporting an error in line: file.write("Hello World!") error: AttributeError: 'NoneType' object has no attribute 'write' Question is, If python is failed to open given file, 'except' block executes and it has to return, but control