[Python-Dev] Raw string syntax inconsistency

Terry Reedy tjreedy at udel.edu
Sun Jun 17 19:54:14 CEST 2012


On 6/17/2012 10:59 AM, "Martin v. Löwis" wrote:
>> So, while PEP 414 will allow u"" to run unmodified, ur"" will still
>> need to be changed to something else, because that partially escaped
>> behaviour isn't available in 3.x and we don't want to reintroduce it.
>
> Given that the PEP currently explicitly supports ur, I think the
> reversal of the reversal will need some discussion in the PEP.

Definitely. The current version of the PEP is contradictory.

"Combination of the unicode prefix with the raw string prefix will also 
be supported, just as it was in Python 2.

No changes are proposed to Python 3's actual Unicode handling, only to 
the acceptable forms for string literals."

Because there is an (unintuitive and obviously forgettable) interaction 
effect between 'u' and 'r' in 2.7, truly supporting 'ur', *just as it 
was in Python 2*, means changing "Python 3's actual Unicode handling".

The premise of the discussion of adding 'u', and of Guido's acceptance, 
was that "it's about as harmless as they come". I do not remember any 
discussion of 'ur' and what it really means in 2.x, and that supporting 
it meant adding back 2.x's interaction effect. Indeed, Nick's version 
goes on to say "This PEP was originally written by Armin Ronacher, and 
Guido's approval was given based on that version." Armin's original 
version (and subsequent edit) only proposed adding 'u' (and 'U') and 
made no mention of 'ur'. Nick's seemingly innocuous addition of also 
adding 'ur' came after Guido's approval, and as discovered, is not so 
innocuous.

I do not think he needs to discuss adding and deleting support, but 
merely state that 'ur' support is not added because 'ur' has a special 
meaning that would require changing literal handling. The sentence about 
supporting 'ur' could be negated and moved after the sentence about not 
changing Unicode handling. A possibility:

"Combination of the unicode prefix with the raw string prefix will not 
be supported because in Python 2, the combination 'ur' has a special 
meaning that would require changing the handling of unicode literals"

-- 
Terry Jan Reedy






More information about the Python-Dev mailing list