summaryrefslogtreecommitdiff
path: root/src/pyparsing.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2013-08-21 08:47:19 +0000
committerPaul McGuire <ptmcg@austin.rr.com>2013-08-21 08:47:19 +0000
commit2080377aa972f78c1a085d15925d744b6381ee59 (patch)
treef2825b2b97ff8944c2a34d9a0c04aeaf5ba14d84 /src/pyparsing.py
parentf997adf8c8930462f4d32c55838da8bb8c769dc3 (diff)
downloadpyparsing-git-2080377aa972f78c1a085d15925d744b6381ee59.tar.gz
Extended "expr(name)" shortcut (same as "expr.setResultsName(name)") to accept "expr()" as a shortcut for "expr.copy()".
Diffstat (limited to 'src/pyparsing.py')
-rw-r--r--src/pyparsing.py13
1 files changed, 9 insertions, 4 deletions
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