-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On Apr 06, 2011, at 11:04 AM, John Arbash Meinel wrote:
In other words, parse_version will return a tuple for each version string, that is compatible with StrictVersion but also accept arbitrary version and deal with them so they can be compared:
from pkg_resources import parse_version as V V('1.2')
('00000001', '00000002', '*final')
V('1.2b2')
('00000001', '00000002', '*b', '00000002', '*final')
V('FunkyVersion')
('*funkyversion', '*final')
bzrlib has certainly used 'version_info' as a tuple indication such as:
version_info = (2, 4, 0, 'dev', 2)
and
version_info = (2, 4, 0, 'beta', 1)
and
version_info = (2, 3, 1, 'final', 0)
etc.
This is mapping what we could sort out from Python's "sys.version_info".
It's probably worth specifying the __version_info__ tuple in more detail in either PEP 386 or 396. I think more detail should go *somewhere*, and it feels like it could go in either PEP. Maybe Tarek can chime in on that.
The *really* nice bit is that you can do:
if sys.version_info >= (2, 6): # do stuff for python 2.6(.0) and beyond
Doing that as:
if sys.version_info >= ('000000002', '000000006'):
is pretty ugly.
I personally often do tests against sys.hexversion, which is a little less ugly (maybe ;).
if sys.hexversion >= 0x20600f0: # 2.6 or 2.7
- -Barry