This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Seth.Troisi, docs@python, ezio.melotti, r.david.murray, terry.reedy
Date 2011-05-28.21:59:26
SpamBayes Score 2.7498608e-09
Marked as misclassified No
Message-id <1306619967.54.0.339467441473.issue12162@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-05-28 21:59:27terry.reedysetrecipients: + terry.reedy, ezio.melotti, r.david.murray, docs@python, Seth.Troisi
2011-05-28 21:59:27terry.reedysetmessageid: <1306619967.54.0.339467441473.issue12162@psf.upfronthosting.co.za>
2011-05-28 21:59:27terry.reedylinkissue12162 messages
2011-05-28 21:59:26terry.reedycreate