[Python-checkins] cpython (3.2): #15920: fix doctests in Doc/howto/regex.rst. Patch by Chris Jerdonek.

ezio.melotti python-checkins at python.org
Mon Sep 17 04:37:37 CEST 2012


http://hg.python.org/cpython/rev/f98f46f7f11b
changeset:   79037:f98f46f7f11b
branch:      3.2
parent:      79035:bc5c5b79b7e1
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Mon Sep 17 05:29:47 2012 +0300
summary:
  #15920: fix doctests in Doc/howto/regex.rst.  Patch by Chris Jerdonek.

files:
  Doc/howto/regex.rst |  26 +++++++++++++-------------
  1 files changed, 13 insertions(+), 13 deletions(-)


diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -260,7 +260,7 @@
 
    >>> import re
    >>> p = re.compile('ab*')
-   >>> p
+   >>> p  #doctest: +ELLIPSIS
    <_sre.SRE_Pattern object at 0x...>
 
 :func:`re.compile` also accepts an optional *flags* argument, used to enable
@@ -372,7 +372,7 @@
 
    >>> import re
    >>> p = re.compile('[a-z]+')
-   >>> p
+   >>> p  #doctest: +ELLIPSIS
    <_sre.SRE_Pattern object at 0x...>
 
 Now, you can try matching various strings against the RE ``[a-z]+``.  An empty
@@ -390,7 +390,7 @@
 result in a variable for later use. ::
 
    >>> m = p.match('tempo')
-   >>> m
+   >>> m  #doctest: +ELLIPSIS
    <_sre.SRE_Match object at 0x...>
 
 Now you can query the :class:`MatchObject` for information about the matching
@@ -429,7 +429,7 @@
 
    >>> print(p.match('::: message'))
    None
-   >>> m = p.search('::: message') ; print(m)
+   >>> m = p.search('::: message'); print(m)  #doctest: +ELLIPSIS
    <_sre.SRE_Match object at 0x...>
    >>> m.group()
    'message'
@@ -458,7 +458,7 @@
 instances as an :term:`iterator`::
 
    >>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')
-   >>> iterator
+   >>> iterator  #doctest: +ELLIPSIS
    <callable_iterator object at 0x...>
    >>> for match in iterator:
    ...     print(match.span())
@@ -480,7 +480,7 @@
 
    >>> print(re.match(r'From\s+', 'Fromage amk'))
    None
-   >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998')
+   >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998')  #doctest: +ELLIPSIS
    <_sre.SRE_Match object at 0x...>
 
 Under the hood, these functions simply create a pattern object for you
@@ -682,7 +682,7 @@
    For example, if you wish to match the word ``From`` only at the beginning of a
    line, the RE to use is ``^From``. ::
 
-      >>> print(re.search('^From', 'From Here to Eternity'))
+      >>> print(re.search('^From', 'From Here to Eternity'))  #doctest: +ELLIPSIS
       <_sre.SRE_Match object at 0x...>
       >>> print(re.search('^From', 'Reciting From Memory'))
       None
@@ -694,11 +694,11 @@
    Matches at the end of a line, which is defined as either the end of the string,
    or any location followed by a newline character.     ::
 
-      >>> print(re.search('}$', '{block}'))
+      >>> print(re.search('}$', '{block}'))  #doctest: +ELLIPSIS
       <_sre.SRE_Match object at 0x...>
       >>> print(re.search('}$', '{block} '))
       None
-      >>> print(re.search('}$', '{block}\n'))
+      >>> print(re.search('}$', '{block}\n'))  #doctest: +ELLIPSIS
       <_sre.SRE_Match object at 0x...>
 
    To match a literal ``'$'``, use ``\$`` or enclose it inside a character class,
@@ -723,7 +723,7 @@
    match when it's contained inside another word. ::
 
       >>> p = re.compile(r'\bclass\b')
-      >>> print(p.search('no class at all'))
+      >>> print(p.search('no class at all'))  #doctest: +ELLIPSIS
       <_sre.SRE_Match object at 0x...>
       >>> print(p.search('the declassified algorithm'))
       None
@@ -741,7 +741,7 @@
       >>> p = re.compile('\bclass\b')
       >>> print(p.search('no class at all'))
       None
-      >>> print(p.search('\b' + 'class' + '\b')  )
+      >>> print(p.search('\b' + 'class' + '\b'))  #doctest: +ELLIPSIS
       <_sre.SRE_Match object at 0x...>
 
    Second, inside a character class, where there's no use for this assertion,
@@ -1182,9 +1182,9 @@
 In the following example, the replacement function translates  decimals into
 hexadecimal::
 
-   >>> def hexrepl( match ):
+   >>> def hexrepl(match):
    ...     "Return the hex string for a decimal number"
-   ...     value = int( match.group() )
+   ...     value = int(match.group())
    ...     return hex(value)
    ...
    >>> p = re.compile(r'\d+')

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


More information about the Python-checkins mailing list