graceful version detection?
Carel Fellinger
cfelling at iae.nl
Tue Jun 19 20:04:02 EDT 2001
Ben Collins-Sussman <sussman at collab.net> wrote:
> Paul Prescod wrote:
>> try:
>> import main
>> except SyntaxError:
>> print "This program requires Python 2.0"
> Thanks, I'll try this solution. Now I just need to hunt down a 1.5
> interpreter...
The downside of this approach is that it makes all syntax errors
look like missing Python 2.0 features:(
Why not something similar:
====wrapper module
import sys
try:
# sys.version_info is a python 2.x goodie
sys.version_info[0]
except AttributeError:
# you could extract and test from sys.version here like
# if sys.version[0] == "1":
print "This program requires Python 2.0"
sys.exit(1)
import realProgram
--
groetjes, carel
More information about the Python-list
mailing list