def pipe(*args):
if len(args) < <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>for i in args[:-<NUM_LIT:1>]:<EOL><INDENT>i["<STR_LIT>"] = subprocess.PIPE<EOL><DEDENT>popens = [popen_sp(**args[<NUM_LIT:0>])]<EOL>for i in range(<NUM_LIT:1>, len(args)):<EOL><INDENT>args[i]["<STR_LIT>"] = popens[i - <NUM_LIT:1>].stdout<EOL>popens.append(popen_sp(**args[i]))<EOL>popens[i - <NUM_LIT:1>].stdout.close()<EOL><DEDENT>return popens<EOL>
Takes as parameters several dicts, each with the same
parameters passed to popen.

Runs the various processes in a pipeline, connecting
the stdout of every process except the last with the
stdin of the next process.

Adapted from http://www.enricozini.org/2009/debian/python-pipes/