Boost::Python: List

From Sidvind
Revision as of 16:12, 19 February 2007 by EXt (Talk | contribs)

Jump to: navigation, search

Boost::Python series

Site: boost.org (Documentation)

[edit]

Converting to and from a python lists is easy. If you are after a quick and dirty way see the page about pointer conversion.

This is faster but requires more work since you might need to provide a wrapper for your functions. If you just need the function to be used by python this is the better way. Same goes for returning lists.

Importing

Code: Import a list into C++

{{{2}}}

I think the code basicly explains itself. First we get the number of elements in the list by accessing __len__ from the python list. Secondly we just access one element at a time and retrieves the value.

Exporting

Code: Export a list from C++

<cpp/>