graceful version detection?

Ben Collins-Sussman sussman at red-bean.com
Sun Jun 17 18:29:24 EDT 2001


Please excuse me if this is a common newbie question;  I didn't find it 
in the FAQ or tutorial.

If I write a python script that uses 2.X features, and then run it with 
a 1.X interpreter, I get a bunch of exceptions.  Presumably this happens 
during the initial byte-compilation.

I'd like the script to instead gracefully print:

    "Sorry, this program requires Python 2.0 or higher."

I tried writing some code to do this by parsing `sys.version' at the top 
of my program;  but as I said, the byte-compiler seems to choke first.

What's the correct solution?

Please cc: my email address (sussman at red-bean.com), as I don't read this 
group regularly.

Thanks in advance --

Ben Collins-Sussman
sussman at red-bean.com




More information about the Python-list mailing list