def check_python_version ( ) : # Required due to multiple with statements on one line req_version = ( 2 , 7 ) cur_version = sys . version_info if cur_version >= req_version : print ( "Python version... %sOK%s (found %s, requires %s)" % ( Bcolors . OKGREEN , Bcolors . ENDC , str ( platform . python_version ( ) ) , str ( req_version [ 0 ] ) + "." + str ( req_version [ 1 ] ) ) ) else : print ( "Python version... %sFAIL%s (found %s, requires %s)" % ( Bcolors . FAIL , Bcolors . ENDC , str ( cur_version ) , str ( req_version ) ) )
how to check verson of python being used
Check if the currently running Python version is new enough .
def check_python_version():
    """Check if the currently running Python version is new enough."""
    # Required due to multiple with statements on one line
    req_version = (2, 7)
    cur_version = sys.version_info
    if cur_version >= req_version:
        print("Python version... %sOK%s (found %s, requires %s)" %
              (Bcolors.OKGREEN, Bcolors.ENDC, str(platform.python_version()),
               str(req_version[0]) + "." + str(req_version[1])))
    else:
        print("Python version... %sFAIL%s (found %s, requires %s)" %
              (Bcolors.FAIL, Bcolors.ENDC, str(cur_version),
               str(req_version)))