I need to create a virtual file in memory to trick the system and to let it think that it exists.
I have some scientific program and I heed to provide in some function file for output as argument.
I want to create some file in memory and provide this file to this function.
I do not want to use some temp folders and so on. How do you think, is it possible to create this trick?
The
iolibrary can create in-memory file like objects that act like file handles opened with the typicalf = open(filename, mode). If you would have opened in normal text mode, aStringIOshould do the trick, or if you would have opened the file in binary mode,BytesIOis the way to go.