I'm using the six module in my program, and the code is as follows:
if six.PY2:
do_something()
else:
do_something_else()
The problem with this approach is that, the function do_something_else()
would run only if Python version is 3.4+ due to dependencies. (And not on Py 3.3)
How do I check for this?
Thanks a lot! :)
Since it's a common requirement, six
already provides this one:
six.PY34
It will be true if the Python version is greater or equal than v3.4.
So you could do this:
if six.PY2:
do_something()
elif six.PY34:
do_something_else()
else:
# ...do what?