Listing 12. Reading the Entire File at Once

#! /usr/local/bin/python
import sys
import re
data = sys.stdin.readlines()
if data != '':
    # do some processing of the contents of the
    # data variable
    data = re.sub('A-Z]', '=', str(data))
    # end of data processing module
    sys.stdout.write(data)
else:
    sys.stdout.flush()