[Python-Dev] Should PEP 498 specify if rf'...' is valid?

Martin Panter vadmium+py at gmail.com
Tue Oct 27 00:15:00 EDT 2015


On 26 October 2015 at 19:43, MRAB <python at mrabarnett.plus.com> wrote:
> On 2015-10-26 18:45, Sven R. Kunze wrote:
>>
>> On 26.10.2015 16:22, Ethan Furman wrote:
>>>
>>> On 10/23/2015 08:20 AM, Nick Coghlan wrote:
>>>>
>>>> My own objection isn't to allowing "fR" or "fbR", it's to
>>>> allowing the uppercase "F".
>>>>
>>>> I also don't understand why we can't say "if 'f' is part of a
>>>> string prefix, it must be first".
>>>
>>>
>>> Sometimes order matters, and sometimes it does not.  If the order
>>> does not have an impact on the final code, it does not matter, and
>>> making us have to remember an order that does not matter is a
>>> waste.
>>
>>
>> Order that matters? You must be kidding. That would turn different
>> types of string extremely hard to understand because semantics
>> differ.
>>
>> That is, btw., one reason, why I favor a fixed order (alphabetically
>> or something). Easy to remember and no way to misinterpret it.
>>
> In Python 2, how often have you seen prefix "ur" rather than "ru"?
>
> I always used "ur".
>
> How often is alphabetical order used in the prefixes?
>
> If the order isn't alphabetical, then it's going to be some order
> that's harder to remember, so I agree with Ethan here.

In Python 2, ru". . ." is a SyntaxError, despite R coming before U in
the alphabet. And rb". . ." is also a SyntaxError, but in Python 3 it
was made legal.

I don’t see much point restricting the order of rf". . ." versus fr".
. .". Neither flag is particularly more important than the other, and
even if one were, should that one be at the front, or at the end
closer to the string?


More information about the Python-Dev mailing list