[C++-sig] Somewhat beginners error in using boost::python::list from C++?

Stefan Seefeld seefeld at sympatico.ca
Sat Jan 15 15:35:40 CET 2011


On 2011-01-15 09:01, Michael Wand wrote:
> int main() {
>      boost::python::list myList;
>      myList.append("foo");
>      myList.append("fork");
>      cerr<<  "Printing length of list."<<  endl;
>      cerr<<  "Length of myList: "<<  boost::python::len(myList)<<  endl;
> // the above line causes a segfault!
>      cerr<<  "TheList: "<<  boost::python::extract<string>(myList[0])()<<  ","
>                    <<  boost::python::extract<string>(myList[1])()<<  endl;
>      cerr<<  "Finished"<<  endl;
> }

You haven't initialized the Python runtime with "Py_Initialize()".

     Stefan



-- 

       ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list