Skip to content

Instantly share code, notes, and snippets.

@akash-coded
Created March 12, 2020 14:14
Show Gist options
  • Save akash-coded/eeb635814c07fd7d1d441cacffe5541d to your computer and use it in GitHub Desktop.
Save akash-coded/eeb635814c07fd7d1d441cacffe5541d to your computer and use it in GitHub Desktop.
Try with resources, except when you can't and finally, make things work.
try:
with open('hshhj.txt', mode = 'r'):
print("File opened")
except FileNotFoundError as e:
print("Error opening file")
print(e)
finally:
print("Some operation independent of file contents")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment