]> granicus.if.org Git - python/commitdiff
The example regex should be a raw string.
authorRaymond Hettinger <python@rcn.com>
Thu, 28 Feb 2013 19:11:11 +0000 (11:11 -0800)
committerRaymond Hettinger <python@rcn.com>
Thu, 28 Feb 2013 19:11:11 +0000 (11:11 -0800)
Doc/library/collections.rst

index be551dc8a2cd71a35a39f904bbcd476f1cfc1f2d..0fc7fac8dcb4ab093614858bde284a9e8ed08733 100644 (file)
@@ -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)]