Listing 13. Writing to Standard Input

#! /usr/local/bin/python
import os
n = 100
try:
    po = os.popen('sed \'s/-/+/g\' > output', 'w')
except IOError:
    exit(0)
while n != 0:
    n = n-1
    po.write('---\n')