(original) (raw)


On Mon, Dec 19, 2016 at 11:50 PM, Chris Barker <chris.barker@noaa.gov> wrote:
Please don't get rid of unicode+literals -- I don't even think we should depreciate it as a recommendation or discourage it.

Maybe a note or two added as to where issues may arise would be good.

I've found importing unicode\_literals to be an excellent way to write py2/3 code. And I have never found a problem.

I'm also hoping that my py2/3 compatible code will someday be py3 only -- and then I'll be really glad that I don't have all those u" all over the place.

Also it does "automagically" do the right thing with, for instance passing a literal to the file handling functions in the os module -- so that's pretty nice.

The number of times you need to add a b"" is FAR fewer than "text" string literals. Let's keep it.

-CHB


Same thing here... also, it helps coding with the same mindset of Python 3, where everything is unicode by default -- and yes, there are problems if you use a unicode in an API that accepts bytes on Python 2, but then, you can also have the same issues on Python 3 -- you need to know and keep track on the bytes vs unicode everywhere (although they're syntactically similar to declare, they're not the same thing) and I find that there are less places where you need to put b'' than u'' (if you code with unicode in mind in Python 2)...

On the ideal world, Python 2 would actually be improved to accept unicode on the places where Python 3 accepts unicode (such as subprocess.Popen, etc) to make it easier in porting applications that actually do the "right" thing on Python 2 to go to Python 3.

Best Regards,

Fabio​