[Python-checkins] cpython (2.7): The example regex should be a raw string.

raymond.hettinger python-checkins at python.org
Thu Feb 28 20:11:20 CET 2013


http://hg.python.org/cpython/rev/6ae4938256c6
changeset:   82430:6ae4938256c6
branch:      2.7
parent:      82426:0eb3949aa2b6
user:        Raymond Hettinger <python at rcn.com>
date:        Thu Feb 28 11:11:11 2013 -0800
summary:
  The example regex should be a raw string.

files:
  Doc/library/collections.rst |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -51,7 +51,7 @@
 
     >>> # 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)]

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list