<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_python_executable(conn):
 """ Try to determine the remote Python version so that it can be used when executing. Avoids the problem of different Python versions, or distros that do not use ``python`` but do ``python3`` """

    # executables in order of preference:
    executables = ['python3', 'python', 'python2.7']
    for executable in executables:
        conn.logger.debug('trying to determine remote python executable with %s' % executable)
        out, err, code = check(conn, ['which', executable])
        if code:
            conn.logger.warning('skipping %s, was not found in path' % executable)
        else:
            try:
                return out[0].strip()
            except IndexError:
                conn.logger.warning('could not parse stdout: %s' % out)

    # if all fails, we just return whatever the main connection had
    conn.logger.info('Falling back to using interpreter: %s' % conn.interpreter)
    return conn.interpreter