graceful version detection?

John Roth johnroth at ameritech.net
Wed Jun 20 14:49:22 EDT 2001


Just my .02 cents on this one. Python, like most other languages I know,
doesn't have any clean syntax for checking this. I think all languages
should
have something like a "requires" or a "standards" statement that declares
the minimum compiler level required, as well as the highest level that the
maintainer(s) have verified it under. For example:

requires 2.0, 2.1, tkinter

Unfortunately, it isn't there. If it was, compliant compilers would simply
refuse
to compile it, with an understandable error message.

John Roth

"Ben Collins-Sussman" <sussman at red-bean.com> wrote in message
news:3B2D2F44.50007 at red-bean.com...
> 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