Is there any way to calculate length of list passed from python to C++? I want do do
something like this, but list class lacks length (or anything similar) method:
class Awesome{
  public:
    void awesomeMethod(const boost::python::list& list_of_something){
      list_of_something.length() // suprisingly there's no such method
    } 
};
                Like Python, you should use the free function len() to get the length. Try
boost::python::len(list_of_something)
                        It's called len, not length, and it's not a method but a free-standing function (Python does not use length methods, but length protocol and len() function).
return boost::python::len(list_of_something);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With