Parsing and comparing version strings (was: Odd version scheme)

Ben Finney ben+python at benfinney.id.au
Thu Feb 12 20:20:14 EST 2015


Gisle Vanem <gvanem at yahoo.no> writes:

> That's exactly what they do now in IPython/utils/version.py with
> the comment:
>   Utilities for version comparison
>   It is a bit ridiculous that we need these.
>
> Not sure why this is "ridiculous".

Right, versions are effectively a special type [0], specifically
*because* they intentionally don't compare as scalar numbers or strings.
It's not “ridiculous” to need custom comparisons when that's the case.

Python even comes with support for version parsing and comparison in the
standard library [1]. So if anything's “ridiculous”, it's the act of
re-implementing that and getting it wrong.

(Or maybe that such an important part of the standard library is
largely undocumented.)


[0] <URL:https://wiki.python.org/moin/Distutils/VersionComparison>
[1] Unfortunately undocumented, like much of the Distutils API. Try
    <URL:http://epydoc.sourceforge.net/stdlib/distutils.version.StrictVersion-class.html>.

-- 
 \              “Programs must be written for people to read, and only |
  `\        incidentally for machines to execute.” —Abelson & Sussman, |
_o__)              _Structure and Interpretation of Computer Programs_ |
Ben Finney




More information about the Python-list mailing list