Failing gracefully when installed Python is too old?

Piet van Oostrum piet at
Mon Jul 16 15:05:04 EDT 2001

>>>>> grante at (Grant Edwards) (GE) writes:

GE> I can't figure out a way for a Python program to fail
GE> gracefully if somebody attempts to run it with a version of
GE> Python that's too old.

GE> Checking sys.hexversion at runtime won't work because the
GE> program might not even parse.  For example, attempting to run
GE> a program containing list comprehensions under 1.5.2.

GE> Is there any way to check the version at compile time?

You can write anothe very small module that just imports the main module
and catches the exception.
Piet van Oostrum <piet at>
Private email: P.van.Oostrum at

More information about the Python-list mailing list