[Python-ideas] raw strings
taleinat at gmail.com
Mon Oct 1 22:51:26 CEST 2007
On 10/1/07, Guido van Rossum <guido at python.org> wrote:
> Not in this case. It's more the philosophical distinction -- are raw
> strings meant primarily to hold regexes or Windows pathnames? These
> two use cases have opposite requirements for trailing backslash
> treatment. I know the original use case that caused them to be added
> to the language is regexes, and that's still the only one I use on a
> regular basis.
>From a teaching (and simplicity) viewpoint, having these be "raw
strings" instead of "regexp strings" would be better. The current
behavior is a snag I always have to mention when teaching Python, and
students are often caught by this once or twice.
As for my experience with regexps, the current behavior is only useful
when using both single and double quotes in a single regexp string; I
can't recall when I last did so.
On 10/1/07, Clark Maurer <cmaurer at slickedit.com> wrote:
> Two quotes should be one single quote. Otherwise, specifying both
> quote characters in regexes is an issue.
>From the teaching point of view, the preferred behavior for "raw
strings" would be no escaping for quotes - make them escape-less,
period. Mixing single and double quotes would be done by concatenating
strings. With Python's terse string concatenation I don't see the need
for special escaping for only one character to support a rare use
More information about the Python-ideas