Modify examples to be both Python 2 and 3 compatible

For removing dependency on 2to3
This commit is contained in:
William S Fulton 2020-08-15 16:46:01 +01:00
commit 89bee6a7fa
37 changed files with 368 additions and 388 deletions

View file

@ -11,7 +11,7 @@ class PyCallback(example.Callback):
example.Callback.__init__(self)
def run(self):
print "PyCallback.run()"
print("PyCallback.run()")
# Create an Caller instance
@ -20,8 +20,8 @@ caller = example.Caller()
# Add a simple C++ callback (caller owns the callback, so
# we disown it first by clearing the .thisown flag).
print "Adding and calling a normal C++ callback"
print "----------------------------------------"
print("Adding and calling a normal C++ callback")
print("----------------------------------------")
callback = example.Callback()
callback.thisown = 0
@ -29,9 +29,9 @@ caller.setCallback(callback)
caller.call()
caller.delCallback()
print
print "Adding and calling a Python callback"
print "------------------------------------"
print("")
print("Adding and calling a Python callback")
print("------------------------------------")
# Add a Python callback (caller owns the callback, so we
# disown it first by calling __disown__).
@ -40,9 +40,9 @@ caller.setCallback(PyCallback().__disown__())
caller.call()
caller.delCallback()
print
print "Adding and calling another Python callback"
print "------------------------------------------"
print("")
print("Adding and calling another Python callback")
print("------------------------------------------")
# Let's do the same but use the weak reference this time.
@ -53,5 +53,5 @@ caller.delCallback()
# All done.
print
print "python exit"
print("")
print("python exit")