Checking Python version in a program

Fredrik Lundh effbot at telia.com
Thu Mar 2 18:54:23 CET 2000


Preston Landers <prestonlanders at my-deja.com> wrote:
> I wish it were as simple as
>
> if int(version) < int(required_version): spew()
>
> but the 1.5.x scheme doesn't mesh well with that...

note that [1, 5, 2] < [1, 6].  in other words,
this will do what you want:

import string, sys

version = string.split(string.split(sys.version)[0], ".")

if map(int, version) < [1, 5, 2]:
    print "sorry"

</F>





More information about the Python-list mailing list