Listing 11. Reading from Standard Input

#! /usr/local/bin/python
import sys
while 1:
    data = sys.stdin.read(256)
    if data != '':
        # do some processing of the contents of
        # the data variable
        data = '#'+data
        # end of data processing command group
        sys.stdout.write(data)
    else:
        sys.stdout.flush()
        break