I need to detect Python version and execute code just for this version.
I want to use one file for each version of Python.
I need to detect Python version and execute code just for this version.
I want to use one file for each version of Python.
Use sys.version_info
.
import sys
PY3 = sys.version_info[0] == 3
if PY3:
# execute code for python 3
import file_you_want_for_py3
else:
# execute code for python 2
import file_you_want_for_py2