diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2014-04-13 16:17:24 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2014-04-13 16:17:24 +0000 |
commit | d6e299c73a89ec2c4dc19b359a92288464032e0d (patch) | |
tree | 1912e97234ddad6417205b06190a4e11cadb4a10 /src | |
parent | 66efeb5df07c90bbf4905f1cb4d36889aeca42a9 (diff) | |
download | pyparsing-git-d6e299c73a89ec2c4dc19b359a92288464032e0d.tar.gz |
Added ParseResults.pprint method
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES | 8 | ||||
-rw-r--r-- | src/pyparsing.py | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/CHANGES b/src/CHANGES index fe358a2..ff6ca36 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -10,6 +10,14 @@ Version 2.0.2 - April, 2014 - Added "locatedExpr(expr)" helper, to decorate any returned tokens
with their location within the input string.
+- Added "pprint()" method to ParseResults, to simplify troubleshooting
+ and prettified output. Now instead of importing the pprint module
+ and then writing "pprint.pprint(result)", you can just write
+ "result.pprint()". This method also accepts addtional positional and
+ keyword arguments (such as indent, width, etc.), which get passed
+ through directly to the pprint method
+ (see http://docs.python.org/2/library/pprint.html#pprint.pprint).
+
- Removed deprecation warnings when using '<<' for Forward expression
assignment. '<<=' is still preferred, but '<<' will be retained
for cases whre '<<=' operator is not suitable (such as in defining
diff --git a/src/pyparsing.py b/src/pyparsing.py index 799a150..cd45a03 100644 --- a/src/pyparsing.py +++ b/src/pyparsing.py @@ -58,7 +58,7 @@ The pyparsing module handles some of the problems that are typically vexing when """
__version__ = "2.0.2"
-__versionTime__ = "8 April 2014 08:55"
+__versionTime__ = "13 April 2014 11:10"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -69,6 +69,7 @@ import warnings import re
import sre_constants
import collections
+import pprint
#~ sys.stderr.write( "testing pyparsing module, version %s, %s\n" % (__version__,__versionTime__ ) )
__all__ = [
@@ -649,6 +650,9 @@ class ParseResults(object): out.append(_ustr(v))
return "".join(out)
+ def pprint(self, *args, **kwargs):
+ pprint.pprint(self.asList(), *args, **kwargs)
+
# add support for pickle protocol
def __getstate__(self):
return ( self.__toklist,
|