Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Python comparing version strings problem - alternatives to StrictVersion?

Options
  • 26-10-2016 9:16pm
    #1
    Registered Users Posts: 5,555 ✭✭✭


    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