Title: in-memory-only file object from string
The mmap module should do what you are looking for. It allows you to store data in memory (hence the name memory map) and treat it as both a string and a file.


From: [EMAIL PROTECTED] on behalf of bobrik
Sent: Wed 8/23/2006 2:56 PM
To: python-list@python.org
Subject: in-memory-only file object from string

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.

--
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to