Obtaining Python version

John Nagle nagle at animats.com
Mon Aug 3 18:19:22 EDT 2009


This works, but it seems too cute:

 >>> pyver = map(int,sys.version.split()[0].split('.'))
 >>> print(pyver)
[2, 6, 1]

Is it guaranteed that the Python version string will be in a form
suitable for that?  In other words, does "sys.version" begin

N.N.N other stuff

in all versions, and will it stay that way?  Are there ever
non-numeric versions, like "3.2.rc1"?

				John Nagle



More information about the Python-list mailing list