summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2022-07-18 05:45:46 -0500
committerptmcg <ptmcg@austin.rr.com>2022-07-18 05:45:46 -0500
commitde477062d2650f9c10148530290c35daf9926d3e (patch)
tree54a7db4b078b8868e5d4e14e78ac204fa1c0a568
parente543ec9b46add9179b1fd70981d0fbc509b6d320 (diff)
downloadpyparsing-git-de477062d2650f9c10148530290c35daf9926d3e.tar.gz
Fix typo in HowToUsePyparsing.rst ("aslist" should be "asdict"). Issue #431.
-rw-r--r--docs/HowToUsePyparsing.rst14
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/HowToUsePyparsing.rst b/docs/HowToUsePyparsing.rst
index 57e5a03..569af51 100644
--- a/docs/HowToUsePyparsing.rst
+++ b/docs/HowToUsePyparsing.rst
@@ -356,6 +356,8 @@ methods for code to use are:
^
FAIL: Expected numeric digits, found end of text (at char 4), (line:1, col:5)
+.. _set_results_name:
+
- ``set_results_name(string, list_all_matches=False)`` - name to be given
to tokens matching
the element; if multiple tokens within
@@ -826,7 +828,8 @@ Other classes
['abc', ['100', '200', '300'], 'end']
If the ``Group`` is constructed using ``aslist=True``, the resulting tokens
- will be a Python list instead of a ParseResults_.
+ will be a Python list instead of a ParseResults_. In this case, the returned value will
+ no longer support the extended features or methods of a ParseResults_.
- as a dictionary
@@ -838,8 +841,9 @@ Other classes
input text - in addition to ParseResults_ listed as ``[ [ a1, b1, c1, ...], [ a2, b2, c2, ...] ]``
it also acts as a dictionary with entries defined as ``{ a1 : [ b1, c1, ... ] }, { a2 : [ b2, c2, ... ] }``;
this is especially useful when processing tabular data where the first column contains a key
- value for that line of data; when constructed with ``aslist=True``, will
- return an actual Python ``dict`` instead of a ParseResults_.
+ value for that line of data; when constructed with ``asdict=True``, will
+ return an actual Python ``dict`` instead of a ParseResults_. In this case, the returned value will
+ no longer support the extended features or methods of a ParseResults_.
- list elements that are deleted using ``del`` will still be accessible by their
dictionary keys
@@ -871,6 +875,10 @@ Other classes
(The ``pprint`` module is especially good at printing out the nested contents
given by ``as_list()``.)
+ If a ParseResults_ is built with expressions that use results names (see _set_results_name) or
+ using the ``Dict`` class, then those names and values can be extracted as a Python
+ dict using ``as_dict()``.
+
Finally, ParseResults_ can be viewed by calling ``dump()``. ``dump()`` will first show
the ``as_list()`` output, followed by an indented structure listing parsed tokens that
have been assigned results names.