PageRenderTime 46ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

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

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