Python version dilemma

Aahz Maruch aahz at panix.com
Mon Aug 27 21:28:13 CEST 2001


In article <9me54u$4a3$1 at flood.xnet.com>,
C. Michael Pilato <cmpilato at typhoon.xnet.com> wrote:
>
>I would be shocked if this is the first time the following question
>has been posted to this list, but I'm willing to risk asking it again
>anyway.
>
>I have a set of scripts that use 2.1 syntax.  Now, I'd really like
>these scripts to, when run by the 1.5 interpreter, gracefully state
>that version 2 is required.  However, my code fails during the
>compilation stage with the 1.5 interpreter (SyntaxError's and such),
>and so never gets the chanced to execute a code portion that might
>print a pretty (or at least useful) error message.
>
>Is there *any way* to do what I'm trying to do.  A few hours of Google
>searching and book reading has turned up nothing thus far.

The only simple way is to use two modules and tell your users to use the
first module, which then imports the second.  It may be convenient to
use a package for the purpose.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

"Plus ca change, plus c'est la meme chose."



More information about the Python-list mailing list