Created
February 2, 2016 02:46
-
-
Save dhermes/823dd28cfa37289769f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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