def migPipe(deme, k, pipein, pipeout, selection, replacement=None):
 emigrants = selection(deme, k)
 if (replacement is None):
  immigrants = emigrants
 else:
  immigrants = replacement(deme, k)
 pipeout.send(emigrants)
 buf = pipein.recv()
 for (place, immigrant) in zip(immigrants, buf):
  indx = deme.index(place)
  deme[indx] = immigrant

def migPipe ( deme , k , pipein , pipeout , selection , replacement = None ) : emigrants = selection ( deme , k ) if ( replacement is None ) : immigrants = emigrants else : immigrants = replacement ( deme , k ) pipeout . send ( emigrants ) buf = pipein . recv ( ) for ( place , immigrant ) in zip ( immigrants , buf ) : indx = deme . index ( place ) deme [ indx ] = immigrant
migration using pipes between initialized processes .