cooler piping

Donn Cave donn at drizzle.com
Thu Nov 20 20:16:22 EST 2003


Quoth Csaba Henk <csaba at phony_for_avoiding_spam.org>:
...
| However, its not the case: there is os.pipe() which is low-level and its
| usage is complex, and there are several popen functions which are simple to
| use, but they evaluate the given command by passing it to the shell,
| throwing me back to the middle of the quotation hell I want to escape from.
| A typical case is when one tries to find out some info about a file by
| invoking the "file" command on it: the name of the file can be (almost)
| anything, thus doing os.popen("file " + filename) gets sucked easily (here
| filename is a variable storing the name of the file). (Don't tell me there
| is a module in Python with the fucntionality of the file command [I don't
| know wheter is], I could find out many similar examples.) What would be cool
| is having a function with an execvp-like syntax: if I could do something
| like os.fancypopen('file', ['file',fname])...

You may find that popen2.popen2() already comes pretty close to this.
You may specify a command string, but you also may specify a list of
strings for execvp.  The only difference is that you supply only the
argument list, and the file to execute is inferred from its first element.

	Donn Cave, donn at drizzle.com




More information about the Python-list mailing list