Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tpetazzoni/f9bebe40d51f90163ab0746db5dd665f to your computer and use it in GitHub Desktop.
Save tpetazzoni/f9bebe40d51f90163ab0746db5dd665f to your computer and use it in GitHub Desktop.
>>> import distutils.version
>>> a = distutils.version.LooseVersion("2-3-15")
>>> hasattr(a, 'version')
True
>>> b = distutils.version.LooseVersion("2.3.1")
>>> hasattr(b, 'version')
True
>>> a < b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.8/distutils/version.py", line 52, in __lt__
c = self._cmp(other)
File "/usr/lib64/python3.8/distutils/version.py", line 337, in _cmp
if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'
>>> print(a.version)
[2, '-', 3, '-', 15]
>>> print(b.version)
[2, 3, 1]
>>> a = distutils.version.LooseVersion("1-3-3")
>>> b = distutils.version.LooseVersion("3.4.5")
>>> a < b
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment