pythonversionversioninfo

How to find latest version number of python from web?


I'm looking for getting latest version of python.

For example, I can find latest version of golang at https://go.dev/VERSION?m=text

Is there same thing as golang?


Solution

  • This may not be the best way to do it but you can interrogate the latest downloadable with this:

    import requests
    from bs4 import BeautifulSoup
    
    (r := requests.get('https://www.python.org/downloads/')).raise_for_status()
    soup = BeautifulSoup(r.text, 'lxml')
    if (a := soup.find_all('a', class_='button')):
        print(a[0].text.split()[-1])
    

    Output:

    3.10.7