New PEP: The directive statement

Aahz Maruch aahz at panix.com
Fri Mar 23 14:58:31 EST 2001


In article <3ABBA837.DEB8AB1B at san.rr.com>, Darren New  <dnew at san.rr.com> wrote:
>Andrew Kuchling wrote:
>>
>> It's really a documentation issue; people who release software should
>> say "I've tested this with Python 2.0", and people with 1.5.2 or 2.1
>> will have to look out, and perhaps provide patches to fix problems.
>
>What is the Python mechanism for ensuring a particular (or minimal) version
>of Python is being used? Is there one?  I'm talking about something like
>Tcl's [package require Tcl 8.3] or some such.

assert (sys.version_info[0] >= 2) and (sys.version_info[1] > 0)

(If you want this to work on Python 1.5.2 and earlier, use sys.version.)
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

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

"I won't accept a model of the universe in which free will, omniscient
gods, and atheism are simultaneously true."  -- M



More information about the Python-list mailing list