From: Raymond Hettinger <python@rcn.com> Date: Thu, 28 Feb 2013 19:11:11 +0000 (-0800) Subject: The example regex should be a raw string. X-Git-Tag: v2.7.4rc1~66 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dce969d2b05238755771bd9c65d86df182ab8390;p=python The example regex should be a raw string. --- diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index be551dc8a2..0fc7fac8dc 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -51,7 +51,7 @@ For example:: >>> # Find the ten most common words in Hamlet >>> import re - >>> words = re.findall('\w+', open('hamlet.txt').read().lower()) + >>> words = re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]