You don't mean:
>>> sys.version
either?
--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
| >>> import sys
| >>> sys.version
| '2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)]'
| >>> sys.version_info
| (2, 6, 2, 'final', 0)
| >>>
"easiest" depends on purpose; e.g. version for display or for logging
exactly what the customer is running. version_info (or a prefix of it)
is the best for things like conditional imports etc
E.g.
py_version = sys.version_info[:2]
if py_version == (2, 3):
from sets import Set as set
Cheers,
John
python -c 'import sys; print sys.version[:3]'
Regards,
Antonio
Note also that the definition of tuple comparison help you here:
if (2, 1, 1) < sys.version_info < (2, 3):
...
elif (2, 5) <= sys.version_info <= (2, 6, 2, 'final'):
...
else:
print('Untested')
--Scott David Daniels
Scott....@Acm.Org
sys.hexversion contains the version number encoded as a single
integer. This is
guaranteed to increase with each version, including proper support for
non-
production releases. For example, to test that the Python interpreter
is at
least version 1.5.2, use:
if sys.hexversion >= 0x010502F0:
# use some advanced feature
...
else:
# use an alternative implementation or warn the user
...
"""
if sys.hexversion >= 0x020600F0: runningPython26 = True
else: runningPython26 = False
if sys.hexversion >= 0x030000F0: runningPython3 = True
else: runningPython3 = False
if runningPython3:
from tkinter import *
import tkinter.filedialog as tk_FileDialog
from io import StringIO
else:
from Tkinter import *
import tkFileDialog as tk_FileDialog
from StringIO import StringIO
</pre>
-- Steve Ferg