Advertisement
Guest User

Untitled

a guest
Jul 18th, 2010
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # PARENT
  3. import subprocess
  4. import sys
  5.  
  6. test = "./child.py"
  7. process = subprocess.Popen(test, shell=True,
  8. stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  9. for i in range(1000):
  10. process.stdin.write("%d\n" % (i,))
  11. process.stdin.flush()
  12. output = process.stdout.readline()
  13. print "OUTPUT =", output.strip()
  14.  
  15. process.stdin.close()
  16. process.wait()
  17.  
  18.  
  19.  
  20. #!/usr/bin/env python
  21. # CHILD
  22. import sys
  23.  
  24. while True:
  25. line = sys.stdin.readline()
  26. if not line:
  27. break
  28. number = int(line)
  29. sys.stdout.write("%d\n" % (number ** 2,))
  30. sys.stdout.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement