THRIFT-1857 Python 3 Support
Client: Python
Patch: Thomas Bartelmess, Eevee (Alex Munroe), helgridly, Christian Verkerk, Jeroen Vlek, Nobuaki Sukegawa
This closes #213 and closes #680
diff --git a/tutorial/py/PythonClient.py b/tutorial/py/PythonClient.py
index 0554ee1..c4559ff 100755
--- a/tutorial/py/PythonClient.py
+++ b/tutorial/py/PythonClient.py
@@ -21,7 +21,7 @@
import sys, glob
sys.path.append('gen-py')
-sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0])
+sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0])
from tutorial import Calculator
from tutorial.ttypes import *
@@ -49,10 +49,10 @@
transport.open()
client.ping()
- print 'ping()'
+ print('ping()')
sum = client.add(1,1)
- print '1+1=%d' % (sum)
+ print(('1+1=%d' % (sum)))
work = Work()
@@ -62,22 +62,22 @@
try:
quotient = client.calculate(1, work)
- print 'Whoa? You know how to divide by zero?'
- except InvalidOperation, io:
- print 'InvalidOperation: %r' % io
+ print('Whoa? You know how to divide by zero?')
+ except InvalidOperation as e:
+ print(('InvalidOperation: %r' % e))
work.op = Operation.SUBTRACT
work.num1 = 15
work.num2 = 10
diff = client.calculate(1, work)
- print '15-10=%d' % (diff)
+ print(('15-10=%d' % (diff)))
log = client.getStruct(1)
- print 'Check log: %s' % (log.value)
+ print(('Check log: %s' % (log.value)))
# Close!
transport.close()
-except Thrift.TException, tx:
- print '%s' % (tx.message)
+except Thrift.TException as tx:
+ print(('%s' % (tx.message)))