def _chain_procs(procs_args, **kwargs):
 last_stdout = None
 procs = []
 for (i, args) in enumerate(procs_args):
  proc_kwargs = kwargs.copy()
  if (i > 0):
   proc_kwargs['stdin'] = last_stdout
  if (i < (len(procs_args) - 1)):
   proc_kwargs['stdout'] = PIPE
  proc = Popen(args, **proc_kwargs)
  last_stdout = proc.stdout
  procs.append(proc)
 return procs

def _chain_procs ( procs_args , ** kwargs ) : last_stdout = None procs = [ ] for ( i , args ) in enumerate ( procs_args ) : proc_kwargs = kwargs . copy ( ) if ( i > 0 ) : proc_kwargs [ 'stdin' ] = last_stdout if ( i < ( len ( procs_args ) - 1 ) ) : proc_kwargs [ 'stdout' ] = PIPE proc = Popen ( args , ** proc_kwargs ) last_stdout = proc . stdout procs . append ( proc ) return procs
input: list of lists of command line arguments .