3 ms·
Not quite, because the py2 library is often not compatible with unicode literals, and also because if you flip the switch in a module it changes the API of any
by smallnamespace 10y ago
Not quite, because the py2 library is often not compatible with unicode literals, and also because if you flip the switch in a module it changes the API of any functions that returned strings. That might break calling code from other modules.
So then you might have to add code to work around these issues, code that is needed in neither pure py2 or pure py3 -- hence making it a weird detour.
In general, it is more compelling to use `unicode_literals` when back-porting new or existing Python 3 code to Python 2/3 than when porting existing Python 2 code to 2/3 [1]
[1] http://python-future.org/unicode_literals.html http://python-future.org/unicode_literals.html
- dagss 10y agoRight.. our codebase is already unicode all over the place because otherwise we could not i18n properly. So we basically have py2 unicode-correct code with encode/decode in the proper places for interfacing witg stdlib. I didn't consider people might use str and not unicode for text..