title: Python tempfile with modules that require path as string
body: <p>Recently, I have discovered the &quot;tempfile&quot; module, which enables you to easily create temporary files used by your Python program.<br />
  However, while trying to use the module, I have discovered an issue - <strong>Most Python modules that manipulate or create files, use the path to the file (as a string) as inputs from the user (or a programmer).</strong></p>
  <p>That means, that code like this one will raise an error:</p>
  <pre class="lang-py prettyprint-override"><code>import tempfile
  
  with tempfile.NamedTemporaryFile(suffix=&quot;.jpg&quot;) as tempfileimg:
  
      image = generate_random_image()
      save_image(image, tempfileimg)      # Type Error (expected path to file)
      upload_image_to_cloud(tempfileimg)  # Type Error (expected path to file)
  
      # In this example, both `save_image` and `upload_image_to_cloud` functions
      # expect to receive the path to the file and not the &quot;opened file object&quot;.
  </code></pre>
  <p>I have tried using <code>tempfileimg.name</code> to get the path to the temporary file as a string, but because temporary files are located in a special folder on the machine, writing files in the regular methods will raise an expectation:</p>
  <pre><code>PermissionError: [Errno 13] Permission denied: 'C:\\Users\\MyUserName\\AppData\\Local\\Temp\\tmpvq81yj2v.jpg'
  </code></pre>
  <p>How can I solve this issue?</p>