On Sun, Jun 17, 2012 at 9:45 PM, Christian Heimes <li...@cheimes.de> wrote: > Hello, > > the topic came up on the python-users list today. The raw string syntax > has a minor inconsistency. The ru"" notation is a syntax error although > we support rb"". Neither rb"" nor ru"" are supported on Python 2.7. > > Python 3.3: > > works: r"", ur"", br"", rb"" > syntax error: ru"" > > Python 2.7: > > works: r"", ur"", br"" > syntax error: ru"", rb"" > > The ru"" notation isn't necessary for Python 2 compatibility but it's > still an inconsistency. The docs [1] also state that 'r' is a prefix, > not a suffix. On the other hand the lexical definition doesn't mention > the u"" notation yet.
I suggest we drop the "raw Unicode" syntax altogether for 3.3, as its current implementation in 3.x doesn't match 2.x, and the 2.x "not really raw" mechanism only made any sense because the language support for embedding Unicode characters directly in string literals wasn't as robust as it is in 3.x (Terry Reedy pointed out this problem a while back, but I failed to follow up on it at the time). $ python Python 2.7.3 (default, Apr 30 2012, 21:18:11) [GCC 4.7.0 20120416 (Red Hat 4.7.0-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print(ur'\u03B3') γ $ ./python Python 3.3.0a4+ (default:cfbf6aa5c9e3+, Jun 17 2012, 15:25:45) [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> ur'\u03B3' '\\u03B3' [73691 refs] >>> r'\u03B3' '\\u03B3' [73691 refs] >>> '\u03B3' 'γ' Better to have a noisy conversion error than silently risking producing different output. 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. I've created http://bugs.python.org/issue15096 to track this reversion. Cheers, Nick. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com