summaryrefslogtreecommitdiff
path: root/Examples/python/std_vector/runme.py
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2009-08-18 20:56:02 +0000
committerLorry <lorry@roadtrain.codethink.co.uk>2012-09-25 16:59:08 +0000
commit9f8a09ed743cedd9547bf0661d518647966ab114 (patch)
tree9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/python/std_vector/runme.py
downloadswig-tarball-master.tar.gz
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/python/std_vector/runme.py')
-rw-r--r--Examples/python/std_vector/runme.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Examples/python/std_vector/runme.py b/Examples/python/std_vector/runme.py
new file mode 100644
index 0000000..d248ccb
--- /dev/null
+++ b/Examples/python/std_vector/runme.py
@@ -0,0 +1,36 @@
+# file: runme.py
+
+import example
+
+# Call average with a Python list...
+
+print example.average([1,2,3,4])
+
+# ... or a wrapped std::vector<int>
+
+v = example.IntVector(4)
+for i in range(len(v)):
+ v[i] = i+1
+print example.average(v)
+
+
+# half will return a Python list.
+# Call it with a Python tuple...
+
+print example.half((1.0, 1.5, 2.0, 2.5, 3.0))
+
+# ... or a wrapped std::vector<double>
+
+v = example.DoubleVector()
+for i in [1,2,3,4]:
+ v.append(i)
+print example.half(v)
+
+
+# now halve a wrapped std::vector<double> in place
+
+example.halve_in_place(v)
+for i in range(len(v)):
+ print v[i], "; ",
+print
+