Skip to content

Instantly share code, notes, and snippets.

@carlos-jenkins
Created April 13, 2016 00:39
Show Gist options
  • Save carlos-jenkins/55ec04c8a9ba345b6b968c5ca11595f9 to your computer and use it in GitHub Desktop.
Save carlos-jenkins/55ec04c8a9ba345b6b968c5ca11595f9 to your computer and use it in GitHub Desktop.
Creating named temporal files in Python
from os import fdopen
from json import dumps
from tempfile import mkstemp
payload = {'one': 1}
osfd, tmpfile = mkstemp()
with fdopen(osfd, 'w') as pf:
pf.write(dumps(payload))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment