blob: 3f1106d590197e25f81a20e304167f83a5454a56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# 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)
print([i for i in v])
|