[Python-Dev] \u and \U escapes in raw unicode string literals

"Martin v. Löwis" martin at v.loewis.de
Sat May 12 00:48:00 CEST 2007

> Using double backslashes won't cause that reaction:
> os.stat("c:\\windows\\system32\\user32.dll")

Please refer to the subject. We are talking about raw strings.

>> Windows path names are one of the two primary applications of raw
>> strings (the other being regexes).
> IMHO the primary use case are regexps

It's not a matter of opinion. It's a statistical fact that these
are the two cases where people use raw strings most.

> and for those you'd
> definitely want to be able to put Unicode characters into your
> expressions.

For regular expressions, you don't need them as part of the
string literal syntax: The re parser itself could support \u,
just like it supports \x today.

> BTW, if you use ur"..." for your expressions today (which you should
> if you parse text), then nothing will change when removing the
> 'u' prefix in Py3k.

How do you know? Py3k hasn't been released, yet.


More information about the Python-Dev mailing list