B
bobrik
Hello,
how to create a file object whose contents I initialize from a string
and which is purely in memory?
I can make a workaround like this:
filecontents = "Very interesting stuff ... "
file = os.tmpfile ()
file.write (filecontents)
file.seek (0)
procedure (fileobject = file)
but this creates a file on harddisk. Instead I would like to use
something like:
filecontents = "Very interesting stuff ... "
file = stringfile (filecontents)
procedure (fileobject = file)
Is this possible somehow? I appreciate any help.
how to create a file object whose contents I initialize from a string
and which is purely in memory?
I can make a workaround like this:
filecontents = "Very interesting stuff ... "
file = os.tmpfile ()
file.write (filecontents)
file.seek (0)
procedure (fileobject = file)
but this creates a file on harddisk. Instead I would like to use
something like:
filecontents = "Very interesting stuff ... "
file = stringfile (filecontents)
procedure (fileobject = file)
Is this possible somehow? I appreciate any help.