[Python-bugs-list] [ python-Feature Requests-793798 ] Redirect file output into variables

SourceForge.net noreply at sourceforge.net
Fri Oct 24 15:49:28 EDT 2003


Feature Requests item #793798, was opened at 2003-08-23 17:52
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=793798&group_id=5470

Category: Python Library
Group: None
>Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: Markus Elfring (elfring)
Assigned to: Martin v. Löwis (loewis)
Summary: Redirect file output into variables

Initial Comment:
The PHP programming language provides output control 
functions (http://de.php.net/manual/en/ref.outcontrol.php, 
e.
g. "ob_get_contents"). I am looking for 
similar
functionality to use with phyton.

1. I suggest 
to add a parameter that specifies a 
variable
name.
open(file, flags[, mode[, variable 
name]])
fdopen(fd[, mode[, bufsize[, variable 
name]]])


2. Another technique is to implement a 
virtual file system that converts variables into special 
files.
Has anybody tried to create a file system interface for 
variables before?


A code example can be found with a 
similar feature request for 
TCL.
https://sourceforge.net/tracker/?func=detail&aid=792990&group_id=10894&atid=360894

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-10-24 21:49

Message:
Logged In: YES 
user_id=21627

This is not a reason to reopen the feature request. Ask in
comp.lang.python if you need help.

----------------------------------------------------------------------

Comment By: Markus Elfring (elfring)
Date: 2003-10-24 15:51

Message:
Logged In: YES 
user_id=572001

I can not see by the 
description "http://www.python.org/doc/current/lib/module-
StringIO.html" how STDOUT 
(http://www.python.org/doc/current/lib/os-fd-ops.html) can 
be redirected.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-10-20 23:09

Message:
Logged In: YES 
user_id=21627

This is already available. StringIO/cStringIO allow readily
to output streams into memory. Use it like this

variable = cStringIO.StringIO()


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=793798&group_id=5470



More information about the Python-bugs-list mailing list