New PEP: The directive statement
Martin von Loewis
loewis at informatik.hu-berlin.de
Sat Mar 24 05:20:27 EST 2001
aahz at panix.com (Aahz Maruch) writes:
> >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)
That will fail on Python 3.0, so you better write
assert sys.verion_info >= (2,0)
It also works for specific modules, e.g.
assert xml.version_info >= (0,6,4)
Regards,
Martin
More information about the Python-list
mailing list