From 09681b470092b3296d654fee96eb580483affc8a Mon Sep 17 00:00:00 2001 From: ptmcg Date: Thu, 25 Jun 2020 08:22:33 -0500 Subject: Collapse _checkRecursion methods; moved 3.0.0 summary from CHANGES to whats_new_in_3_0_0.rst; cleaned up docstrings, Word() examples, restored setName() docstring; added example to ParseException.explain() --- pyparsing/exceptions.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pyparsing/exceptions.py') diff --git a/pyparsing/exceptions.py b/pyparsing/exceptions.py index 51eed66..2a10180 100644 --- a/pyparsing/exceptions.py +++ b/pyparsing/exceptions.py @@ -163,6 +163,21 @@ class ParseBaseException(Exception): Returns a multi-line string listing the ParserElements and/or function names in the exception's stack trace. + + Example:: + + expr = pp.Word(pp.nums) * 3 + try: + expr.parseString("123 456 A789") + except pp.ParseException as pe: + print(pe.explain(depth=0)) + + prints:: + + 123 456 A789 + ^ + ParseException: Expected W:(0-9), found 'A' (at char 8), (line:1, col:9) + """ return self.explain_exception(self, depth) -- cgit v1.2.1