Last active
December 5, 2024 10:42
-
-
Save gregneagle/2c5b535c723aea5d3fc7 to your computer and use it in GitHub Desktop.
Proper software version comparisons in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% python | |
Python 2.7.6 (default, Sep 9 2014, 15:04:36) | |
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> os_vers_1 = "10.9.5" | |
>>> os_vers_2 = "10.10" | |
>>> os_vers_2 > os_vers_1 | |
False | |
>>> from distutils import version | |
>>> version.LooseVersion(os_vers_2) > version.LooseVersion(os_vers_1) | |
True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment