# 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 always gets called in the "end", even if an exception ocurrs. You can use this to make sure open resources are closed (for instance, a DB connection, a file, etc).
I think you misunderstood the semantics.
Your logic should be in the "try", you should deal with exceptions in the "except" block, and "finally" executes no matter how your method terminates, use it to clean up.