import sys
import os
import arcpy

def message(*msgs):
    """
    Print given messages to the Python window using either arcpy functions or
    print() depending on the script's running environment. This is necessary
    because arcpy will not pass print() statements to the geoprocessing window.
    """
    exe = os.path.split(sys.executable)[1]
    for msg in msgs:
        if exe.lower() == 'python.exe':
            print(msg)
        else: # e.g., 'arcmap.exe', 'arccatalog.exe', etc
            arcpy.AddMessage(msg)
