check interpreter version before running script

djo notarealaddress at notarealaddress.com
Tue Apr 5 10:09:27 EDT 2005


Josef Meile wrote:
> What's about:
>  >>> import sys
>  >>> print sys.version_info
> (2, 1, 3, 'final', 0)

Python 1.5.2 (#1, Mar  3 2001, 01:35:43)  [GCC 2.96 20000731 (Red 
Hat Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
 >>> import sys
 >>> sys.version_info
Traceback (innermost last):
   File "<stdin>", line 1, in ?
AttributeError: version_info


...which the OP may have known, since they suggested sys.version, 
which *is* availible in pre-2.0.


My own messy solution involves a shell script installer which 
runs a 1.5-safe Python script which installs a needs-2.2 Python 
script.  But I needed an installer for other reasons.  This would 
be ugly for a single script.


djo



More information about the Python-list mailing list