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