hi Chris, Thank you for your advice. I will use tmpfs as a temperory file system to detail with it.
Cheers, Cun Zhang On Sat, Jan 15, 2011 at 4:51 AM, Chris Rebert <c...@rebertia.com> wrote: > On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang <apzc2...@gmail.com> wrote: > > Hi,all > > I hope use cStringIO to create virtual file, but my customed function > which > > is from a shared library imported by ctypes > > just accepts a filename(string type) as parameter. > > > > So I'm wondering whether there is any method that make the virtual file > > created by cStringIO like a normal file which have > > a filename, so it can be called by my functions. > > That's not possible. (c)StringIO presents a file-like interface at the > Python level, but under the covers, it's not implemented using > anything like a normal file; thus, it doesn't have a presence on any > filesystem. I would suggest using a temporary file > (http://docs.python.org/library/tempfile.html ) for communicating with > the C module, writing the contents of the StringIO object to the > temporary file if necessary. > (It's probably also possible to hack something together with FUSE, but > it'd be a slow, platform-specific kludge.) > > Cheers, > Chris > -- > http://blog.rebertia.com > -- ======================================== Cun Zhang Ph.D. Candidate LNM,Institute of Mechanics Chinese Academy of Sciences Beijing, 100190, China Tel:86-10-82544204 http://www.edwardpku.com/cun ========================================
-- http://mail.python.org/mailman/listinfo/python-list