import sys
if sys.version_info.major == 3:
# Do something
elif sys.version_info.major == 2:
# Do something else
Anyone has any better and cleaner solution, perhaps more wxPython-like?
'Cause my lines are purely Python.
I like this approach
PY3 = sys.version_info[0] == 3
if PY3:
doSomething()
else:
doSomethingElse()
If you're using Phoenix then the six module has been copied into the wx.lib package, and it has that and a bunch of other stuff to help you write code that is compatible with both 2.7 and 3.