[Tutor] Convert string to file handle

John Fouhy john at fouhy.net
Mon Nov 27 23:50:28 CET 2006


On 28/11/06, Shitiz Bansal <shitizb at yahoo.com> wrote:
> Hi,
> i have a string abc.
> i need a file handle f  pointing to a file which contains this string.
> is there any way i can achieve this without actually writing the contents to
> a file and then opening it? for performance reasons i want to run this
> entire process within the physical memory!

Have a look at the StringIO module:
http://www.python.org/doc/current/lib/module-StringIO.html

-- 
John.


More information about the Tutor mailing list