check for a certain Python version

Roy Smith roy at panix.com
Tue Dec 20 09:21:41 EST 2011


In article <hef6s8-id5.ln1 at satorlaser.homedns.org>,
 Ulrich Eckhardt <ulrich.eckhardt at dominolaser.com> wrote:

> Hi!
> 
> I'd like to give my users a meaningful error message when they are using 
> obsolete Python versions. Is there some kind of best practice or recipe 
> for that? Specifically, the case is a bunch of unittests that use 
> features new to Python 2.7.

>>> sys.version_info
(2, 6, 1, 'final', 0)


major, minor, _, _, _ = sys.version_info
self.assertGreaterEqual(minor, 7, "You, dude, fix your python")



More information about the Python-list mailing list