1[section boost_python_list.hpp] 2[section Introduction] 3Exposes a [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] for the Python [@http://www.python.org/doc/current/lib/typesseq-mutable.html list] type. 4[endsect] 5[section Class `list`] 6Exposes the [@http://www.python.org/doc/current/lib/typesseq-mutable.html mapping protocol] of Python's built-in `list` type. The semantics of the constructors and member functions defined below can be fully understood by reading the [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] concept definition. Since `list` is publicly derived from [link object_wrappers.boost_python_object_hpp.class_object `object`], the public `object` interface applies to `list` instances as well.`` 7namespace boost { namespace python 8{ 9 class list : public object 10 { 11 public: 12 list(); // new list 13 14 template <class T> 15 explicit list(T const& sequence); 16 17 template <class T> 18 void append(T const& x); 19 20 template <class T> 21 long count(T const& value) const; 22 23 template <class T> 24 void extend(T const& x); 25 26 template <class T> 27 long index(T const& x) const; 28 29 template <class T> 30 void insert(object const& index, T const& x); // insert object before index 31 32 object pop(); // remove and return item at index (default last) 33 object pop(long index); 34 object pop(object const& index); 35 36 template <class T> 37 void remove(T const& value); 38 39 void reverse(); // reverse *IN PLACE* 40 41 void sort(); // sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1 42 43 template <class T> 44 void sort(T const& value); 45 }; 46}} 47`` 48[endsect] 49[section Example] 50`` 51using namespace boost::python; 52 53// Return the number of zeroes in the list 54long zeroes(list l) 55{ 56 return l.count(0); 57} 58`` 59[endsect] 60[endsect] 61