Check Python version from inside script? Run Pythons script in v2 compatibility mode?

Jeremiah Dodds jeremiah.dodds at gmail.com
Fri Jul 7 03:22:19 EDT 2017


"Ben S. via Python-list" <python-list at python.org> writes:

> Can I somehow check from inside a Python script if the executing Python engine is major version v2 or v3?

import sys
sys.version_info[0]

(If you just need to print() consistently, you should follow Terry's advice)



More information about the Python-list mailing list