Skip to content

Instantly share code, notes, and snippets.

@OddBloke
Last active September 16, 2015 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OddBloke/3216436e74c8901c5827 to your computer and use it in GitHub Desktop.
Save OddBloke/3216436e74c8901c5827 to your computer and use it in GitHub Desktop.
f = open(...)
try:
json.loads(f.read())
except ValueError:
print "Invalid JSON"
raise
finally:
f.close()
@evildmp
Copy link

evildmp commented Sep 16, 2015

but won't the following behave identically?:

f = open(...)
try:
    json.loads(f.read())
except ValueError:
    print "Invalid JSON"
    raise
f.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment