Obtaining Python version

Xavier Ho contact at xavierho.com
Tue Aug 4 13:34:44 CEST 2009

On Tue, Aug 4, 2009 at 8:30 PM, Yinon Ehrlich <yinon.me at gmail.com> wrote:

> Hi,
> Easy way to test for Python version:
> if sys.hexversion >= 0x2060100:
>  pass

Great suggestion. I just tested it on my newly installed Python 3.1 (as of

>>> import sys
>>> "%X" % sys.hexversion

That's genius - '301' for Python 3.1, and '00F0' is r31!

I'm definitely going to use this more often in the future.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090804/6ac52a24/attachment.html>

More information about the Python-list mailing list