Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Python comparing version strings problem - alternatives to StrictVersion?

  • 26-10-2016 08:16PM
    #1
    Registered Users, Registered Users 2 Posts: 5,767 ✭✭✭


    Below i am using StrictVersion in Python.

    logging.info("Comparing " + deployment_version.strip() + " with " + latest_green_iso.strip())
    if deployment_version.strip() <= latest_green_iso.strip():

    logging.info("Yep less")

    If the first comparison string is less than the second, the next line prints "Yep less".
    As you can see, if the first 2 parts of Strings are alike, the third seems to be (wrongly) assumed to be greater, so python will not print the message.

    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,294] Comparing 1.31.9 with 1.31.11
    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,295] Comparing 1.31.9 with 1.31.11
    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,295] Comparing 1.31.8 with 1.31.11
    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,295] Comparing 1.31.6 with 1.31.11
    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,295] Comparing 1.31.4 with 1.31.11
    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,295] Comparing 1.30.90 with 1.31.11
    [INFO][get_suitable_deployment.py:151][2016-10-26 21:07:39,295] Yep less
    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,295] Comparing 1.30.88 with 1.31.11
    [INFO][get_suitable_deployment.py:151][2016-10-26 21:07:39,295] Yep less
    [INFO][get_suitable_deployment.py:149][2016-10-26 21:07:39,296] Comparing 1.30.79 with 1.31.11
    [INFO][get_suitable_deployment.py:151][2016-10-26 21:07:39,296] Yep less


    What is up with that? Any alternative method to compare version Strings?


Comments

Advertisement