Entry
How can I check that the Python version is recent enough to run my program?
Dec 18th, 2009 12:09
new acct, sheana krat, Nathan Wallace, Fredrik Lundh, Oleg Broytmann
Note that (1, 5, 2) < (1, 6). in other words, this will do what you
want:
import sys
version = sys.version_info[:3]
if map(int, version) < (1, 5, 2):
print "sorry"
I can be better to not check the version - this will bound poor user to
one version. Instead, check for the feature you need. You need a
library? Try to import it and fall back gracefully:
try:
import pagecast_lib
except ImportError:
print_error()
if "I_need_IT" not in pagecast_lib:
print_another_error()