diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2012-11-23 08:54:10 +0000 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2012-11-23 08:54:10 +0000 |
commit | 774e46526945ea91265734a2dc82d15eed515577 (patch) | |
tree | 734ae210c20a98f01fe029f7e6eeb7a93b4617fb /src/examples/dfmparse.py | |
parent | 6b12041d4656f4cda910f24acda8d71013166fbd (diff) | |
download | pyparsing-git-774e46526945ea91265734a2dc82d15eed515577.tar.gz |
Clean up examples to be Python 3 compatible
Diffstat (limited to 'src/examples/dfmparse.py')
-rw-r--r-- | src/examples/dfmparse.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/examples/dfmparse.py b/src/examples/dfmparse.py index 1523497..96afbad 100644 --- a/src/examples/dfmparse.py +++ b/src/examples/dfmparse.py @@ -48,7 +48,7 @@ object_name = identifier object_type = identifier
# Integer and floating point values are converted to Python longs and floats, respectively.
-int_value = Combine(Optional("-") + Word(nums)).setParseAction(lambda s,l,t: [ long(t[0]) ] )
+int_value = Combine(Optional("-") + Word(nums)).setParseAction(lambda s,l,t: [ int(t[0]) ] )
float_value = Combine(Optional("-") + Optional(Word(nums)) + "." + Word(nums)).setParseAction(lambda s,l,t: [ float(t[0]) ] )
number_value = float_value | int_value
@@ -121,7 +121,7 @@ nested_object << Group(object_definition) #################
def printer(s, loc, tok):
- print tok,
+ print(tok, end=' ')
return tok
def get_filename_list(tf):
@@ -162,12 +162,12 @@ def main(testfiles=None, action=printer): failures.append(f)
if failures:
- print '\nfailed while processing %s' % ', '.join(failures)
- print '\nsucceeded on %d of %d files' %(success, len(testfiles))
+ print('\nfailed while processing %s' % ', '.join(failures))
+ print('\nsucceeded on %d of %d files' %(success, len(testfiles)))
if len(retval) == 1 and len(testfiles) == 1:
# if only one file is parsed, return the parseResults directly
- return retval[retval.keys()[0]]
+ return retval[list(retval.keys())[0]]
# else, return a dictionary of parseResults
return retval
|