Terry J. Reedy <tjre...@udel.edu> added the comment:

The doc consistently does NOT quote re's in the text. Rather, they are shaded 
gray, both in Windows help version and html version. So this one should not be 
treated differently.

Most of the confusion reported is due to not reading the intro paragraphs. I 
almost suggested closing this without action. However,  after saying to use the 
r prefix, the doc omits them from examples when not absolutely needed. In 
particular,

>>> m = re.search('(?<=-)\w+', 'spam-egg')

Why does \w work without being doubled or protected (and it does, I checked), 
while \1 does not? Hell if I know. So even though that example works, it should 
be changed. The doc should teach the rule "if strings contains '\', prefix with 
'r'" rather than "test and add 'r' if it fails", or "learn the exact list of 
when needed", which is not given and unknown to me and most any beginner.

I advocate the same practice in the RE How To, which also has at least one 
example with '\' but without 'r':
>>> p = re.compile('\d+')

I do not think we need another example other than those in the text.

----------
keywords: +patch
nosy: +terry.reedy
stage:  -> needs patch
versions: +Python 2.7, Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12162>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to