3
\$\begingroup\$

There are important differences between Python 2 and 3, so it's often useful to know which version of the interpreter is running your code. The straightforward method is something like this:

def get_python_version():
    import sys
    return sys.version_info.major

But you can exploit other differences to come up with other solutions to this. My favorite so far is this:

def get_python_version():
    version = 3;[2 for version in range(3)]
    return version

What's the most creative/diabolical/entertaining snippet you can come up with that returns the Python version?

\$\endgroup\$

closed as too broad by mınxomaτ, Addison Crump, Morgan Thrapp, Alex A. Nov 18 '15 at 21:28

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.