[C++-sig] Clearing lists in boost-python

Stefan Seefeld stefan at seefeld.name
Wed Jun 22 17:15:30 CEST 2011

On 2011-06-22 11:04, charles75 wrote:
> Hi,
> I've been trying to clear a list of dictionaries from a list without
> success.
> The code below is a simple example of what I'm trying to achieve.
> dict a, b;
> list mylist;
> mylist.append(a);
> mylist.append(b);
> mylist.clear();
> When I type in the last statement I get the error below from the linker
> ‘class boost::python::list’ has no member named ‘clear’.

Right, and neither does the Python 'list' type have such a method.

> Is there another way of clearing the list?

In Python you'd probably do something like

   del mylist[:]

The equivalent of that in C++ is




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

More information about the Cplusplus-sig mailing list