[C++-sig] Boost.python: extracting an array

Randolph Fritz rfritz333 at gmail.com
Mon Oct 12 06:14:46 CEST 2009


Is there any way to extract a vector of floats from a python array?

In Python, can I write something like:
  from array import array
  from bpclass import foo

  vec = array('f', (1,2,3))
  foo ([vec])

And, in C++:
  void bpclass::foo (list v) {
    ... extract< {magic} >(v[0]) ...

Or would it be better to replace the array with a list?
-- 
Randolph Fritz
  design machine group, architecture department, university of washington
rfritz at u.washington.edu -or- rfritz333 at gmail.com



More information about the Cplusplus-sig mailing list