I don't think there is a better way,
And this really isn't all that bad.
except ImportError: # not tested
import json
-#
-# Python 2 and 3, module and script compatability
-# If you know a better way please tell me :(
-#
-
try:
from .renderer import render
except (ValueError, SystemError): # python 2
#!/usr/bin/python
# -*- coding: utf-8 -*-
-#
-# Python 2 and 3, module and script compatability
-# If you know a better way please tell me :(
-#
-
try:
from .tokenizer import tokenize
except (ValueError, SystemError): # python 2