def _is_python_file(filename):
    """Check if the input file looks like a Python script

    Returns True if the filename ends in ".py" or if the first line
    contains "python" and "#!", returns False otherwise.

    """
    if filename.endswith('.py'):
        return True
    with open(filename, 'r') as file_handle:
        first_line = file_handle.readline()
    return 'python' in first_line and '#!' in first_line