summaryrefslogtreecommitdiff
path: root/Examples/python/reference
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-15 16:46:01 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-15 16:46:01 +0100
commit89bee6a7fa2236da8f10bf200abdc4892d4085b8 (patch)
treeb4a6efa27ad38a2e7146a91b6832b80631c0c677 /Examples/python/reference
parent2af35cb4ff80f352aa2f8f2b02bfd31000db4188 (diff)
downloadswig-89bee6a7fa2236da8f10bf200abdc4892d4085b8.tar.gz
Modify examples to be both Python 2 and 3 compatible
For removing dependency on 2to3
Diffstat (limited to 'Examples/python/reference')
-rw-r--r--Examples/python/reference/runme.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Examples/python/reference/runme.py b/Examples/python/reference/runme.py
index 0ff217b02..8a96e03a7 100644
--- a/Examples/python/reference/runme.py
+++ b/Examples/python/reference/runme.py
@@ -6,12 +6,12 @@ import example
# ----- Object creation -----
-print "Creating some objects:"
+print("Creating some objects:")
a = example.Vector(3, 4, 5)
b = example.Vector(10, 11, 12)
-print " Created", a.cprint()
-print " Created", b.cprint()
+print(" Created %s" % a.cprint())
+print(" Created %s" % b.cprint())
# ----- Call an overloaded operator -----
@@ -21,9 +21,9 @@ print " Created", b.cprint()
#
# It returns a new allocated object.
-print "Adding a+b"
+print("Adding a+b")
c = example.addv(a, b)
-print " a+b =", c.cprint()
+print(" a+b = %s" % c.cprint())
# Note: Unless we free the result, a memory leak will occur
del c
@@ -31,9 +31,9 @@ del c
# ----- Create a vector array -----
# Note: Using the high-level interface here
-print "Creating an array of vectors"
+print("Creating an array of vectors")
va = example.VectorArray(10)
-print " va = ", va
+print(" va = %s" % va)
# ----- Set some values in the array -----
@@ -45,17 +45,17 @@ va.set(2, example.addv(a, b))
# Get some values from the array
-print "Getting some array values"
+print("Getting some array values")
for i in range(0, 5):
- print " va(%d) = %s" % (i, va.get(i).cprint())
+ print(" va(%d) = %s" % (i, va.get(i).cprint()))
# Watch under resource meter to check on this
-print "Making sure we don't leak memory."
-for i in xrange(0, 1000000):
+print("Making sure we don't leak memory.")
+for i in range(0, 1000000):
c = va.get(i % 10)
# ----- Clean up -----
-print "Cleaning up"
+print("Cleaning up")
del va
del a