[Python-Dev] PEP 414 - Unicode Literals for Python 3

Terry Reedy tjreedy at udel.edu
Mon Feb 27 19:44:43 CET 2012


On 2/27/2012 1:01 PM, Chris McDonough wrote:
> On Mon, 2012-02-27 at 12:41 -0500, R. David Murray wrote:
>> Eh?  The 2.6 version would also be u('that').  That's the whole point
>> of the idiom.  You'll need a better counter argument than that.
>
> The best argument is that there already exists tons and tons of Python 2
> code that already does:
>
>    u'that'
>
> Needing to change it to:
>
>    u('that')
>
> 1) Requires effort on the part of a from-Python-2-porter to service
>     the aesthetic and populist goal of not having an explicit
>     but redundant-under-Py3 literal syntax that says "this is text".

This is a point, though this would be a one-time conversion by a 2to23 
converter that would be part of other needed conversions, some by hand. 
I presume that most 2.6 code has problems other than u'' when attempting 
to run under 3.x.

> 2) Won't atually meet the aesthetic goal, as
>     it's uglier and slower under *both* Python 2 and Python 3.

Less relevant. The minor ugliness would be in dual-version code, but not 
Python 3 itself.

> So the populist argument remains.. "it's too confusing for people who
> learn Python 3 as a new language to have a redundant syntax".  But we've
> had such a syntax in Python 2 for years with b'', and, as mentioned by
> Armin's PEP single-quoted vs. triple-quoted strings forever.
>
> I just don't understand the pushback here at all.

For one thing, u'' does not solve the problem for 3.1 and 3.2, while u() 
does. 3.2 will be around for years. For one example, it will be in the 
April long-term-support release of Ubuntu. For another, PyPy is working 
on a 3.2 compatible version to come out and be put into use this year.

 > This is such a nobrainer.

I could claim that a solution that also works for 3.1 and 3.2 is a 
nobrainer. It depends on how one weighs different factors.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list