This check shows up several times- can you please create a function, e.g. `is_py2` or `is_py3`?