Requiring a certain version of interpreter?

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Wed Jun 28 07:14:19 EDT 2000


Thomas Wouters wrote in comp.lang.python:
> Python 1.6 has sys.version_info, which is a tuple with version info:
> 
> >>> sys.version_info
> (1, 6, 0, 'alpha', 2)

Hmm, mine doesn't, it seems.

> But no, there is no builtin way to 'require' a version. Most new features
> break cleanly with old versions of Python (like keyword arguments) so the
> usual remedy is to say 'Python 1.5 required!' near the top of the docs, and
> point people there when they complain it doesn't work ;-)
> 
> And for the bug-prevention scheme, you can use 'if sys.version_info[1] < 6:'
> in Python 1.6 (which will, of course, be bugfree.)

The effbot pointed out the neat:

if sys.version_info < (1, 6, 0):

once. Tuples compare dictionary-style.

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
'Oook?'



More information about the Python-list mailing list