Checking Python version in a program
Preston Landers
prestonlanders at my-deja.com
Thu Mar 2 12:52:05 EST 2000
Sorry to followup to a followup to myself, but I realized that this
isn't a very good solution. First of all, it won't work on Python 1.4
(sadly, we still use that for some tasks at my job.)
I'm still interested in seeing a portable version checker...
In article <89m7u3$qdh$1 at nnrp1.deja.com>,
Preston Landers <prestonlanders at my-deja.com> wrote:
> import sys, string
>
> def check_python_version(minimum_version):
>
> """Checks the currently running Python version.
>
> Parameters:
> minimum_version: a tuple/list consisting of major, minor,
> revision integers specifying the minimum required version.
>
> Returns:
> None on success (version is okay)
> otherwise, returns the current version list [major, minor,
> revision]"""
>
> min_major, min_minor, min_rev = minimum_version
>
> version_elements = map(int,
> string.split(string.split(sys.version)[0], "."))
>
> major, minor, rev = version_elements
>
> if major < min_major:
> return version_elements
>
> if minor < min_minor:
> return version_elements
>
> if rev < min_rev:
> return version_elements
>
> return
>
> minimum_version = [1, 5, 2]
>
> print check_python_version(minimum_version)
--
|| Preston Landers <prestonlanders at my-deja.com> ||
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list