could be:
```
mongo_cli = subprocess.Popen(["mongo", "--port", str(port)], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
reply, _ = mongo_cli.communicate(cmd)
```
which I arbitrarily consider to be more elegant :)