[C++-sig] How to use functionality of list.

Roman Yakovenko roman.yakovenko at gmail.com
Thu May 6 09:53:54 CEST 2010

On Thu, May 6, 2010 at 10:24 AM, vishal bayskar
<vishal.bayskar at nechclst.in> wrote:
> Actually I need to extract the item present in the list, so I am trying to
> use methonds of list (just for an example I tried push_back in the below
> example).

I don't understand why do you struggle. The "exposed via an indexing
suite" method allows you to modify and iterate over the list using the
well defined and documented protocol. If you need to use:
* the original function names
  - you can expose it via indexing suite and then add aliases to the functions
* the original function functionality or some unexposed functions
  - you will have to extend the exposed class. Boost.Python interface
allows you to achieve this.

void mylist_push_back( AList& alist, const MyItem& item ){
     alist.push_back( item );


class_< AList >
    < register indexing suite functionality >
    .def( "push_back", &mylist_push_back )

>From Python, your user will not see any difference:

alist = AList()
alist.push_back|( .... )


Roman Yakovenko
C++ Python language binding

More information about the Cplusplus-sig mailing list