[Python-3000-checkins] r57606 - in python/branches/py3k: Doc/library/parser.rst
collin.winter
python-3000-checkins at python.org
Tue Aug 28 08:10:19 CEST 2007
Author: collin.winter
Date: Tue Aug 28 08:10:19 2007
New Revision: 57606
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Doc/library/parser.rst
Log:
Idiom adjustment in the docs for the parser module.
Modified: python/branches/py3k/Doc/library/parser.rst
==============================================================================
--- python/branches/py3k/Doc/library/parser.rst (original)
+++ python/branches/py3k/Doc/library/parser.rst Tue Aug 28 08:10:19 2007
@@ -474,19 +474,17 @@
implement the pattern matching, returning a Boolean and a dictionary of variable
name to value mappings. (See file :file:`example.py`.) ::
- from types import ListType, TupleType
-
def match(pattern, data, vars=None):
if vars is None:
vars = {}
- if type(pattern) is ListType:
+ if isinstance(pattern, list):
vars[pattern[0]] = data
- return 1, vars
- if type(pattern) is not TupleType:
+ return True, vars
+ if not instance(pattern, tuple):
return (pattern == data), vars
if len(data) != len(pattern):
- return 0, vars
- for pattern, data in map(None, pattern, data):
+ return False, vars
+ for pattern, data in zip(pattern, data):
same, vars = match(pattern, data, vars)
if not same:
break
@@ -528,7 +526,7 @@
>>> found, vars = match(DOCSTRING_STMT_PATTERN, tup[1])
>>> found
- 1
+ True
>>> vars
{'docstring': '"""Some documentation.\n"""'}
More information about the Python-3000-checkins
mailing list