Skip to content

Instantly share code, notes, and snippets.

@dhermes
Created February 2, 2016 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhermes/823dd28cfa37289769f3 to your computer and use it in GitHub Desktop.
Save dhermes/823dd28cfa37289769f3 to your computer and use it in GitHub Desktop.
import json
import os
import tempfile
def foo(filename):
with open(filename, 'r') as file_obj:
return file_obj.read()
def bar():
filehandle, filename = tempfile.mkstemp()
payload = {}
os.close(filehandle)
try:
with open(filename, 'w') as file_obj:
json.dump(payload, file_obj)
return foo(filename)
finally:
os.remove(filename)
print(bar())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment