diff options
author | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2014-04-13 16:17:24 +0000 |
---|---|---|
committer | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2014-04-13 16:17:24 +0000 |
commit | 68956b23a525c8f499955ca9e9e72bcc9ca2bbba (patch) | |
tree | 1912e97234ddad6417205b06190a4e11cadb4a10 | |
parent | f267f3121cec683b164854e72179c0a97904a383 (diff) | |
download | pyparsing-68956b23a525c8f499955ca9e9e72bcc9ca2bbba.tar.gz |
Added ParseResults.pprint method
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@264 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-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,
|