Here's another take at a minimal change to the format which includes the things we discussed, adds a few more aliases for the "post" and "dev" markers and also adds optional underscores for more readability. VERSION_RE = re.compile(r''' ^ (?P<version>\d+\.\d+) # minimum 'N.N' (?P<extraversion>(?:\.\d+)*) # any number of extra '.N' segments (?: # pre-release tag _? (?P<prerel>(a|alpha|b|beta|c|rc)) _? (?P<prerelversion>\d+(?:\.\d+)*) )? (?P<postdev> (\.(post|fix|sp)_?(?P<post>\d+))? (\.(dev|pre|build|nightly)_?(?P<dev>\d+))? )? $''', re.VERBOSE + re.I) Examples: 3.2.0a0.20091125 < 3.2.0a1 = 3.2.0_alpha_1 < 3.2.0a1.20091125 < 3.2.0rc1 = 3.2.0c1 < 3.2.0rc1.20091125 = 3.2.0_rc1.20091125 < 3.2.0 < 3.2.0.sp1 = 3.2.0.fix1 = 3.2.0.post1 One nit I have with the order of the N.N.devN version is that it is regarded "more" than any of the pre-release tags, but less than the release itself: 1.0a1 < 1.0rc1 < 1.0.dev456 < 1.0 IMHO, the order should be: 1.0.dev456 < 1.0a1.dev456 < 1.0a1 < 1.0rc1.dev456 < 1.0rc1 < 1.0 since the .dev versions are really only snapshots leading up to some release, i.e. 1.0.dev456 is a snapshot leading up to the first pre-release of the 1.0 :-) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 26 2009)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/