Regex should be a raw string
authorRaymond Hettinger <python@rcn.com>
Fri, 1 Mar 2013 11:30:20 +0000 (03:30 -0800)
committerRaymond Hettinger <python@rcn.com>
Fri, 1 Mar 2013 11:30:20 +0000 (03:30 -0800)
Doc/library/collections.rst

index 6ef114e677981ef84e2091293a38d32aaa77b6e1..a65fe5bfa2ecfc341858dbd0bb6b90b5a9fa71c6 100644 (file)
@@ -210,7 +210,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)]