Python version-checking refactored