I have a Python script that has been written using in Python 2.7. However it will be deployed to a number of different servers, some of which are running Python 2.4. In this case I am happy for the script to simply not run on the servers running Python 2.4. Is there a way I can do this in my Python script or would it be best to put a wrapper around the script?
I have tried doing this:
if sys.version_info[0] < 2.7:
raise Exception("Python 2.7 or a more recent version is required.")
However because Python compiles the code before running it fails during compile when it hits part of the script that does not work in 2.4.