summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2013-08-21 08:47:19 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2013-08-21 08:47:19 +0000
commit455707b40fff2ce15967ef380097b0cd8fc228fc (patch)
treef2825b2b97ff8944c2a34d9a0c04aeaf5ba14d84
parent4a114529b71191c0459f9a2be9e48031f472b7f4 (diff)
downloadpyparsing-455707b40fff2ce15967ef380097b0cd8fc228fc.tar.gz
Extended "expr(name)" shortcut (same as "expr.setResultsName(name)") to accept "expr()" as a shortcut for "expr.copy()".
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@256 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r--src/CHANGES6
-rw-r--r--src/pyparsing.py13
2 files changed, 15 insertions, 4 deletions
diff --git a/src/CHANGES b/src/CHANGES
index 9fe11a4..0a6bc13 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -2,6 +2,12 @@
Change Log
==========
+Version 2.0.1 -
+-----------------------
+- Extended "expr(name)" shortcut (same as "expr.setResultsName(name)")
+ to accept "expr()" as a shortcut for "expr.copy()".
+
+
Version 2.0.1 - July, 2013
--------------------------
- Removed use of "nonlocal" that prevented using this version of
diff --git a/src/pyparsing.py b/src/pyparsing.py
index c078f9c..1d76bbd 100644
--- a/src/pyparsing.py
+++ b/src/pyparsing.py
@@ -57,8 +57,8 @@ The pyparsing module handles some of the problems that are typically vexing when
- embedded comments
"""
-__version__ = "2.0.1"
-__versionTime__ = "16 July 2013 22:22"
+__version__ = "2.0.2"
+__versionTime__ = "21 August 2013 22:22"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -1314,7 +1314,7 @@ class ParserElement(object):
"""Implementation of ~ operator - returns C{L{NotAny}}"""
return NotAny( self )
- def __call__(self, name):
+ def __call__(self, name=None):
"""Shortcut for C{L{setResultsName}}, with C{listAllMatches=default}::
userdata = Word(alphas).setResultsName("name") + Word(nums+"-").setResultsName("socsecno")
could be written as::
@@ -1322,8 +1322,13 @@ class ParserElement(object):
If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be
passed as C{True}.
+
+ If C{name} is omitted, same as calling C{L{copy}}.
"""
- return self.setResultsName(name)
+ if name is not None:
+ return self.setResultsName(name)
+ else:
+ return self.copy()
def suppress( self ):
"""Suppresses the output of this C{ParserElement}; useful to keep punctuation from