title: Python: named in-memory file with actual disk-file semantics?
body: <p>I know I can use <code>io.StringIO</code> or <code>io.BytesIO</code> to return an open file handle that can be written to and read from.</p>
  
  <p>However, I'm looking for a way to make an in-memory region look like a named disk file that has not yet been opened.</p>
  
  <p>The reason I want this is because there are routines which take the name of a disk file as an argument, and these routines then open the file and manipulate it. In some cases, I want the input or output for these routines to be a memory buffer, not a disk file, and for those routines, I can't pass an already-open file handle.</p>
  
  <p>For example, one such routine is <code>Image.save()</code> from <code>PIL</code>, which expects a path name as its argument, not an already open file handle. When using that routine, I'd like the image data to be saved directly to a memory buffer, without any intermediate file IO being performed. There are also many other routines that take path names as arguments for which I would like this same behavior.</p>
  
  <p>Is there any way to accomplish this in python?</p>