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

Terry Reedy tjreedy at udel.edu
Mon Feb 27 21:19:36 CET 2012


On 2/27/2012 1:17 PM, Guido van Rossum wrote:
> On Mon, Feb 27, 2012 at 10:01 AM, Chris McDonough<chrism at plope.com>  wrote:
>> The best argument is that there already exists tons and tons of Python 2
>> code that already does:
>>
>>   u'that'
>
> +1

>> I just don't understand the pushback here at all.  This is such a
>> nobrainer.
>
> I agree. Just let's start deprecating it too, so that once Python 2.x
> compatibility is no longer relevant we can eventually stop supporting
> it (though that may have to wait until Python 4...). We need to send
> *some* sort of signal that this is a compatibility hack and that no
> new code should use it. Maybe a SilentDeprecationWarning?

One possibility: leave Ref Man 2.4.1. *String and Bytes literals* as is.
Add
'''
2.4.1.1 Deprecated u prefix.

To aid people who want to update Python 2 code to also run under Python 
3, string literals may optionally be prefixed with "u" or "U". For this 
purpose, but only for this purpose, the grammar actually reads

stringprefix    ::=  "r" | "R" | "ur" | "Ur" | "uR" | "UR"

Since "u" and "U" will go away again some year, they should only be used 
for such multi-version code and not in code only intended for Python 3. 
See PEP 414.

Version added: 3.3
'''



I think the PEP should have exaggerated statements removed, perhaps be 
shortened, explain how to patch code on installation for 3.1/2, and have 
something at the top pointing to that explanation.

--
Terry Jan Reedy



More information about the Python-Dev mailing list