Skip to content

Instantly share code, notes, and snippets.

@basuke
Last active March 19, 2018 22:12
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 basuke/a7f11f349a69f01f71de05b3efeb9b6c to your computer and use it in GitHub Desktop.
Save basuke/a7f11f349a69f01f71de05b3efeb9b6c to your computer and use it in GitHub Desktop.
Windows tempfile.NamedTemporaryFile : research
a = tempfile.NamedTemporaryFile(delete=False)
file(a.name, 'r')
#>>> <open file 'c:\\users\\basuke\\appdata\\local\\temp\\tmpdclqbx', mode 'r' at 0x0000000009290DB0>
a = tempfile.NamedTemporaryFile(delete=True) # default
file(a.name, 'r')
#---------------------------------------------------------------------------
#IOError Traceback (most recent call last)
#<ipython-input-35-1cb82d16d8f2> in <module>()
#----> 1 file(a.name, 'r')
#IOError: [Errno 13] Permission denied: 'c:\\users\\basuke\\appdata\\local\\temp\\tmpssixrx'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment