[Python-Dev] Re: New functionality in micro releases (was:Documenting branch policy)

David Eppstein eppstein at ics.uci.edu
Mon Sep 8 18:48:50 EDT 2003


In article <5.1.1.6.0.20030908195222.01f1a860 at telecommunity.com>,
 "Phillip J. Eby" <pje at telecommunity.com> wrote:

> It does suggest that being able to specify the version of Python required 
> by a script or module, would be a helpful idiom.  sys.requireversion(), 
> perhaps?  Guess I should make a quick check to be sure you haven't already 
> used the time machine and put this in...  :)
> 
> Of course, the sad bit is that even if there were a sys.requireversion(), 
> it wouldn't be in the versions where it was actually needed: the older ones!

Ok, so what's needed isn't a new sys.feature, it's some short 
boilerplate code you could include in all your python apps, to make sure 
anyone who tries to run it on an old system is informed of the problem.

Something like:

import sys
class PythonTooOld(Exception): pass
if sys.version < '2.2':
    raise PythonTooOld, 'This code needs Python 2.2 or greater.'

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-Dev mailing list