6 Oct 16:13
Fw: Creating a file-like object.
From: Sebastian Noack <sebastian.noack <at> googlemail.com>
Subject: Fw: Creating a file-like object.
Newsgroups: gmane.text.docutils.devel
Date: 2008-10-06 14:14:54 GMT
Subject: Fw: Creating a file-like object.
Newsgroups: gmane.text.docutils.devel
Date: 2008-10-06 14:14:54 GMT
On Sun, 5 Oct 2008 00:10:22 -0400
"David Goodger" <goodger <at> python.org> wrote:
> On Mon, Sep 29, 2008 at 12:13, Sebastian Noack
> <sebastian.noack <at> googlemail.com> wrote:
> > by using publish_file, I can read text from a file-like object and
> > write it to another file-like object, but is there a way to get a
> > file-like object which formats the text while it gets read? Thanks.
>
> I don't understand what you're asking for. Please explain further, and
> include examples of what you'd like (input & output, code samples,
> etc.).
>
I was asking for a way to don't have to publish the complete file at
once. For example:
fd = publish_*(...)
while True:
buffer = fd.read(512)
if len(buffer) == 0: break
sys.stdout.write(buffer)
Note that this is just an example, I know that i can write to
sys.stdout directly. But sometimes i need a file like object to pass it
to an other function which expects a file-like object. In this case i
could create a StringIO but this would be waste of memory and
performance. Thanks
Regards
Sebastian Noack
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
RSS Feed