Use Python tool six
: https://pypi.org/project/six/
This is the documentation: https://six.readthedocs.io/
It will help you with functions for making it easier to migrate across Python 2 and Python 3, considering you want to write Python code that is compatible on both versions.