Full, 100% agreement with Logan. Python has a built-in module for logging information, and it has been tried, tested and fine-tuned to respond to most people's needs.If you are looking for a means of repeating everything to the screen and to a file, an intermediary function (like the relatively functional showGpMessage in Chris' attachment) would probably be your easiest means of doing so, along with the logger module. If, for whatever reason, you find that this is not suitable to your needs, you can have a look at overwriting sys.stdout with an object of your choice, which has a method defined for write().For example:class GetStream(object):
def __init__(self, pLog):
self.terminal = sys.stdout
self.log = pLog
def write(self, message):
self.terminal.write(message)
try:
self.log.write(message)
except UnicodeEncodeError:
self.log.write(message.encode('LATIN-1'))
arcpy.AddMessage(message)
Cheers,Marc