Christian Witts wrote: > Your version will fail if the person is running Python 3.0, 3.1 up > until the 3.3 series which is not good. Neater looking (imo) code > below. > > from sys import version_info, exit > > if version_info[0] == 1 or (version_info[0] == 2 and version_info[1] < 4): > exit("Please upgrade to Python 2.4 or greater.")
This would fail on python < 2.0, as version_info is not available. So you'd want to catch that, if you want to gracefully handle ancient versions of python. You could also just compare the version_info tuple. This is a bit ugly, but it works at least back to 1.5.2: import sys min_version = '2.4' upgrade_msg = 'Please upgrade to Python %s or greater' % min_version try: min = tuple(map(int, min_version.split('.'))) ver = sys.version_info[:3] if ver < min: sys.exit(upgrade_msg) except AttributeError: sys.exit(upgrade_msg) I don't have any python 3.x systems to test though. -- Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose I were a member of Congress, and suppose I were an idiot. But, I repeat myself. -- Mark Twain
pgpHQ1caffg6U.pgp
Description: PGP signature
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor