Version Number Comparison Function
Steve M
sjmaster at gmail.com
Fri Mar 25 13:08:32 EST 2005
I recently saw this:
http://www.egenix.com/files/python/mxTools.html
mx.Tools.verscmp(a,b)
Compares two version strings and returns a cmp() function
compatible value (<,==,> 0). The function is useful for sorting lists
containing version strings.
The logic used is as follows: the strings are compared at each
level, empty levels defaulting to '0', numbers with attached strings
(e.g. '1a1') compare less than numbers without attachement (e.g. '1a1'
< '1).
Keith wrote:
> Is there a function for comparing version numbers?
>
> E.g.
>
> 0.1.0 < 0.1.2
> 1.876b < 1.876c
> 3.2.2 < 3.4
>
> Keith
More information about the Python-list
mailing list