The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
1508 changed files with 125983 additions and 44037 deletions
36
SWIG/Examples/python/std_vector/runme.py
Normal file
36
SWIG/Examples/python/std_vector/runme.py
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue