summaryrefslogtreecommitdiff
path: root/examples/holaMundo.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2020-04-26 10:33:12 -0500
committerptmcg <ptmcg@austin.rr.com>2020-04-26 10:33:12 -0500
commit203fa36d7ae6b79344e4bf13531b77c09f313793 (patch)
tree443459f498f38b97618344c6f707eeaa117cf670 /examples/holaMundo.py
parent813ba3bed433a96e02d82cad2e2940a6850d96a5 (diff)
downloadpyparsing-git-203fa36d7ae6b79344e4bf13531b77c09f313793.tar.gz
change some lambdas to explicit methods for clarity (see discussion in #207); deleted duplicated examples (commit *all* changes this time)
Diffstat (limited to 'examples/holaMundo.py')
-rw-r--r--examples/holaMundo.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/examples/holaMundo.py b/examples/holaMundo.py
index 0589a0d..bb66ca2 100644
--- a/examples/holaMundo.py
+++ b/examples/holaMundo.py
@@ -55,8 +55,13 @@ numreal = Word(nums)
numcomplex = numreal + "+" + numimag
print(numcomplex.parseString("3+5i"))
-# Cambiar a complejo numero durante parsear:
-numcomplex.setParseAction(lambda t: complex("".join(t).replace("i", "j")))
+# Funcion para cambiar a complejo numero durante parsear:
+def hace_python_complejo(t):
+ valid_python = "".join(t).replace("i", "j")
+ return complex(valid_python)
+
+
+numcomplex.setParseAction(hace_python_complejo)
print(numcomplex.parseString("3+5i"))
# Excelente!!, bueno, los dejo, me voy a seguir tirando código...