On Mon, Mar 10, 2003 at 11:52:39AM +1300, Greg Ewing wrote:
Those would be quite different functions, then, unless you proposed to have Python interpret native shell metacharacters on its own too (e.g., set up pipes, do the indicated file redirections, interpolate envars, and fake whatever other shell gimmicks people may use).
What we need is a function which does all those things, but uses some way of specifying them *other* than shell metacharacters. E.g.
os.plumb(("sed", "-e", "s/dead/resting/", "parrots"), ("grep", "norwegian"), output = myfile))
How about this: cmd.sed('-e', 's/dead/resting', 'parrots') / cmd.grep('norwegian') >> myfile or this: def mygrep(pattern): def tran(upstream): for s in upstream: if re.search(pattern, s): yield s return transformation(tran) open('parrots') / (lambda s:s.replace('dead','resting')) / mygrep('norwegian')) >> open('myfile', 'w') This is not some hypothetical syntax - I have a module that actually does this. It can mix python functions, generators and external commands in the same flow, use any iterable object as source, use a file, list or other data consumer as destination and a few more goodies. It's not finished but it mostly works. I don't have much time to work on it, though. oh-dear-what-have-I-done-now-I'll-have-to-finish-it-ly yours, Oren