Christos TZOTZIOY Georgiou wrote:
>
> One of the previous related threads is this (long URL):
>
http://groups-beta.google.com/group/comp.lang.python/messages/f7dea61a92f5e792,5ce65b041ee6e45a,dbf695317a6faa26,19284769722775d2,7599103bb19c7332,abc53bd83cf8f636,4e87b44745a69832,330c5eb638963459,e4c8d
On 29 Mar 2005 00:29:06 -0800, "El Pitonero" <[EMAIL PROTECTED]> wrote:
>Christos TZOTZIOY Georgiou wrote:
>>
>> One of the previous related threads is this (long URL):
>>
>http://groups-beta.google.com/group/comp.lang.python/messages/f7dea61a92f5e792,5ce65b041ee6e45a,dbf695317a6faa26,192847697227
On Fri, 25 Mar 2005 19:23:37 GMT, rumours say that [EMAIL PROTECTED] (Bengt
Richter) might have written:
>On Fri, 25 Mar 2005 17:02:31 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>
>>"Keith" wrote:
>>
>>> Is there a function for comparing version numbers?
>>>
>>> E.g.
>>>
>>> 0.1.0 < 0.1.2
>
On Fri, 25 Mar 2005 17:02:31 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>"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
>
>the following works for many common cases:
>
>import re
>
>def cmpver(a, b):
>
Keith wrote:
distutils is one of the places I looked:
http://www.python.org/doc/2.3.5/lib/module-distutils.html
But I didn't see the functions documented. I am new to Python so I
didn't know where else to look.
The source! I don't think they're documented elsewhere.
Using distutils seems like it w
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 string
distutils is one of the places I looked:
http://www.python.org/doc/2.3.5/lib/module-distutils.html
But I didn't see the functions documented. I am new to Python so I
didn't know where else to look.
Using distutils seems like it would be the most generic and supported
way to compare version numbe
On Mar 26, 2005, at 3:34 AM, 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
FWIW,
>>> from distutils import version
>>> version_list = "3.4 3.2.2 1.867c 1.867b 0.1.2 0.1.0".split()
>>> version_list = map(version.LooseVersion, version_
[Pardon the piggybacking. My news-server does not see the OP's message.]
Fredrik Lundh wrote:
"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
distutils has a set of version classes with comparisons.
In [1]:from distutils import versi
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. b
I can't assume there are the same number of '.'s or there are the same
number of digits per version.
I don't know how the tuple comparison works offhand. But that seems
like it would work if you split it.
The suggestion with the "re" module seems generic enough and looks like
it will work as is.
"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
the following works for many common cases:
import re
def cmpver(a, b):
def fixup(i):
try:
return int(i)
except ValueError:
r
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
>
Not by default AFAIK. How about something like (untested):
def test_version(v1, v2):
v1, v2 = v1.split('.'), v2.
On 25 Mar 2005 07:34:38 -0800, rumours say that "Keith"
<[EMAIL PROTECTED]> might have written:
>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
Convert your version numbers into tuples:
(0, 1, 0) < (0, 1, 2)
(1, 876, 'b') < (1,
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
--
http://mail.python.org/mailman/listinfo/python-list
15 matches
Mail list logo