Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1483,8 +1483,8 @@ Since :meth:`~Pattern.match` and :meth:`~Pattern.search` return ``None``
when there is no match, you can test whether there was a match with a simple
``if`` statement::

if match := re.search(pattern, string):
process(match)
if m := re.search(pattern, string):
process(m)

.. class:: Match

Expand Down Expand Up @@ -1707,10 +1707,10 @@ Checking for a pair
In this example, we'll use the following helper function to display match
objects a little more gracefully::

def displaymatch(match):
if match is None:
def displaymatch(m):
if m is None:
return None
return '<Match: %r, groups=%r>' % (match.group(), match.groups())
return '<Match: %r, groups=%r>' % (m.group(), m.groups())

Suppose you are writing a poker program where a player's hand is represented as
a 5-character string with each character representing a card, "a" for ace, "k"
Expand Down
Loading