title: Permission Denied To Write To My Temporary File
body: <p>I am attempting to create and write to a temporary file on Windows OS using Python. I have used the Python module <code>tempfile</code> to create a temporary file.</p>
  
  <p>But when I go to write that temporary file I get an error <code>Permission Denied</code>. Am I not allowed to write to temporary files?! Am I doing something wrong? If I want to create and write to a temporary file how should should I do it in Python? I want to create a temporary file in the temp directory for security purposes and not locally (in the dir the .exe is executing).</p>
  
  <p><code>IOError: [Errno 13] Permission denied: 'c:\\users\\blah~1\\appdata\\local\\temp\\tmpiwz8qw'</code></p>
  
  <pre><code>temp = tempfile.NamedTemporaryFile().name
  f = open(temp, 'w') # error occurs on this line
  </code></pre>