[Python-ideas] Maybe allow br"" or rb"" e.g., for bytes regexes in Py3?

Terry Reedy tjreedy at udel.edu
Wed Jun 30 19:33:27 CEST 2010

On 6/29/2010 10:04 PM, MRAB wrote:
> Guido van Rossum wrote:
>> On Tue, Jun 29, 2010 at 6:07 PM, Greg Ewing
>> <greg.ewing at canterbury.ac.nz> wrote:
>>> Nick Coghlan wrote:
>>>> According to my local build, we already picked 'br':
>>> Wouldn't "raw bytes" sound better than "bytes raw"?
>>> Or do the Dutch say it differently? :-)
>> I can pronounce "brrrrr" but I can't say "rrrrrb". :-)
> And, of course, Python 2 has 'ur', but not 'ru'.

Even though most say or think 'raw unicode' rather than 'unicode raw'. 
But ur and br strike me as logically correct. In both Py2 and Py3, 
string literals are str literals. The r prefix disables most of the 
cooking of the literal. The u and b prefixes are effectively 
abbreviations for unicode() and bytes() calls on, I presume, the buffer 
part of a partially formed str object. In other words, br'abc' has the 
same effect as bytes(r'abc') but is easier to write and, I presume, 
faster to compute.

It it easy for people who only use ascii chars in Python code to forget 
that Python3 code is now actually a sequence of unicode chars rather 
than of (extended) ascii chars.

Terry Jan Reedy

More information about the Python-ideas mailing list