Am 06.03.17 um 11:12 schrieb Thomas Güttler: > yes, you are right. It's better to leave Python3 clean (without "basestring"). > > I see two ways now. > > > six > ---- > > six.string_types # replacement for basestring > > Source > https://docs.djangoproject.com/en/1.10/topics/python3/#string-handling-with-six > > > future > ------ > > from past.builtins import basestring # pip install future > > Source http://python-future.org/compatible_idioms.html#basestring > > > I have no clue which one I should use.
I would recommend future. It gives you a Python-3-like experience in Python 2. Once you fully transition to Python 3, you only need to remove the future imports and you don't have any dependency on it any more. For example: from builtins import bytes, str gives you Python 3 bytes and strings in Python 2. Now, you can replace basestring with str and it works the same in Python 2 and 3. Maybe this works for you. I am pretty happy with future. Best, Mike _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/