making python 2.3 not complain about generator expressions?

Peter Hansen peter at engcorp.com
Tue Jul 13 08:18:29 EDT 2004


Dan Christensen wrote:

> (By the way, what's the canonical way for a script to find out which
> version of python it is running in?)

Expanding on Andrew Bennetts' answer, you typically do things like
this:

if sys.version_info[:2] >= (2, 2):
     print 'has 2.2 features in place'
elif sys.version_info[:3] == (1, 5, 2):
     print 'precisely version 1.5.2'

etc...

That is, use slices of version_info as desired, comparing with
constant tuples.

-Peter



More information about the Python-list mailing list