PageRenderTime 48ms CodeModel.GetById 44ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Examples/python/std_vector/runme.py

#
Python | 36 lines | 15 code | 14 blank | 7 comment | 6 complexity | 59e43c0bf980b1516b276ec56836379e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1# file: runme.py
 2
 3import example
 4
 5# Call average with a Python list...
 6
 7print example.average([1,2,3,4])
 8
 9# ... or a wrapped std::vector<int>
10
11v = example.IntVector(4)
12for i in range(len(v)):
13      v[i] = i+1
14print example.average(v)
15
16
17# half will return a Python list.
18# Call it with a Python tuple...
19
20print example.half((1.0, 1.5, 2.0, 2.5, 3.0))
21
22# ... or a wrapped std::vector<double>
23
24v = example.DoubleVector()
25for i in [1,2,3,4]:
26      v.append(i)
27print example.half(v)
28
29
30# now halve a wrapped std::vector<double> in place
31
32example.halve_in_place(v)
33for i in range(len(v)):
34      print v[i], "; ",
35print
36