diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2018-09-27 13:30:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 13:30:54 +0300 |
commit | 4dd747e5dbdb244e761e6c2ed144ed792e3148c2 (patch) | |
tree | ce6113fffbdb384d9d114d82809b95a402f80d2a | |
parent | 411f45f24913b8bf091c66917c668c41832a6a42 (diff) | |
parent | 90c8464c53686ca9cd171aff12e50844258f3468 (diff) |
Merge pull request #202 from thuvh/python3_compatible
fix print to compatible with python2 and python3
-rw-r--r-- | contrib/python/example.py | 18 | ||||
-rw-r--r-- | contrib/python/setup.py | 8 |
2 files changed, 16 insertions, 10 deletions
diff --git a/contrib/python/example.py b/contrib/python/example.py index 2a952eca1..93eb60d73 100644 --- a/contrib/python/example.py +++ b/contrib/python/example.py @@ -2,7 +2,7 @@ from moses.dictree import load import sys if len(sys.argv) != 4: - print "Usage: %s table nscores tlimit < query > result" % (sys.argv[0]) + print("Usage: %s table nscores tlimit < query > result" % (sys.argv[0])) sys.exit(0) path = sys.argv[1] @@ -20,13 +20,17 @@ for line in sys.stdin: print result.source for e in result: if e.lhs: - print '\t%s -> %s ||| %s ||| %s' % (e.lhs, + print('\t%s -> %s ||| %s ||| %s' % ( + e.lhs, ' '.join(e.rhs), e.scores, - e.alignment) + e.alignment + ) + ) else: - print '\t%s ||| %s ||| %s' % (' '.join(e.rhs), + print('\t%s ||| %s ||| %s' % ( + ' '.join(e.rhs), e.scores, - e.alignment) - - + e.alignment + ) + ) diff --git a/contrib/python/setup.py b/contrib/python/setup.py index 16f143945..4f62c71b0 100644 --- a/contrib/python/setup.py +++ b/contrib/python/setup.py @@ -1,5 +1,7 @@ +from __future__ import print_function from distutils.core import setup from distutils.extension import Extension + import sys import os @@ -21,19 +23,19 @@ while sys.argv[-1].split('=')[0] in available_switches: if param[0] == '--moses-lib': libdir = param[1] if param[0] == '--cython': - print >> sys.stderr, 'I will be cythoning your pyx files...' + print('I will be cythoning your pyx files...', file=sys.stderr) try: from Cython.Distutils import build_ext suffix = '.pyx' cmdcls['build_ext'] = build_ext except ImportError: - print 'You do not seem to have Cython installed' + print('You do not seem to have Cython installed') if param[0] == '--max-factors': defines['MAX_NUM_FACTORS'] = param[1] if param[0] == '--max-kenlm-order': defines['KENLM_MAX_ORDER'] = param[1] -print >> sys.stderr, 'mosesdir=%s\nincludes=%s\nlibdir=%s\ncmph=%s' % (mosesdir, includes, libdir, with_cmph) +print('mosesdir=%s\nincludes=%s\nlibdir=%s\ncmph=%s' % (mosesdir, includes, libdir, with_cmph), file=sys.stderr) #basic=['z', 'stdc++', 'pthread', 'm', 'gcc_s', 'c', 'boost_system', 'boost_filesystem'] basic=[] |