Determing Python version at runtime

Posted by Gekitsuu on Stack Overflow See other posts from Stack Overflow or by Gekitsuu
Published on 2010-06-10T16:03:38Z Indexed on 2010/06/10 16:12 UTC
Read the original article Hit count: 299

Filed under:
|

The problem I'm having is that I've written code that depends on features in python2.6 so I'm trying to build a check that will produce a useful error if someone tries to run it on a machine with python lower than 2.6. The code I put in to check for the specific version and match it should work fine but the problem I have is the interpreter on a 2.4 machine reads the file and sees a "finally" at the end of my try loop and errors out before it gets far enough into execution for my if statement to handle the version mismatch. Other than changing the magic line to specifically look for /usr/bin/python2.6 is there a way python can handle this sort of thing?

© Stack Overflow or respective owner

Related posts about python

Related posts about beginner