Closed ericdill closed 8 years ago
LMGTFY: http://python-future.org/unicode_literals.html
Before @CJ-Wright diligently puts PRs into more projects we should make a decision on this. To my reading, importing uicode_literals is better than the alternative (putting u
in front of all the strings) for any codebase that has always supported Python 3. Seems like we should leave it in. Did whoever removed it from scikit-beam give a reason?
Correct me if I'm wrong, but I don't think any of the source files in this repository have non-ascii strings or even specify any encoding.
We included unicode_literals
in scikit-beam basically as a copy/paste from matplotlib but removed it during a refactor when @tacaswell mentioned that it was really more trouble than its worth. IIRC it doesn't really prevent any bugs in python 3 and it introduces bugs in python 2. @tacaswell can probably speak better to this.
@klauer pymongo specifies some encoding
@arkilic I mean in the form of https://www.python.org/dev/peps/pep-0263/
@klauer I think you are correct. Which is why adding a blanket unicode_literals
import is the right choice here: it doesn't break anything (there's nothing to break) and it guards against accidentally adding any strings that, without that import, would be interpreted differently by Python 2 and 3.
Of course, if the files never end up with any non-ASCII strings this entire discussion is moot, but I'm not seeing the argument for going through and actively removing these imports.
Where the unicode literals breaks things is if you are doing fun things with programtically creating classes (as type
in py2 does not cope with unicodes) and if you are doing a lot of string based file I/O (At the time we pulled it out of skbeam I was dealing with some other mpl / unicode related headache + that was around when I was working on the vistrails auto-wrapping code which involves a lot of programmatic class generation, hence my pessimism).
At this point if it is not causing harm it is not worth the effort to pull it out.
In scikit-beam we removed all the
from __future__ import unicode_literals
. Should we do the same here?