On 25 Mar 2005 07:34:38 -0800,
"Keith" <[EMAIL PROTECTED]> 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

How about a simple string comparison?

Python 2.3.3 (#1, Mar  9 2004, 14:21:31) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> '0.1.0' < '0.1.2'
True
>>> '1.876b' < '1.876c'
True
>>> '3.2.2' < '3.4'
True
>>> 

Beyond that, there seems to be sufficient variation between version
number schemes, and something "interesting" often happens immediately
before the final version (e.g. "1.0rc4" becomes "1.0"), that you may
have to know something more about where you particular version numbers
come from.

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>
Îâ à Îâ à c = 1
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to