try:
    eval('1 if True else 2')
except SyntaxError:
    raise ImportError('requires ternary support')
from impl import *
How can I check for Python version in a program that uses new language features?