[C++-sig] [boost python] : how to pass a tuple of lists from python to C++

HOUSSEN Franck fghoussen at gmail.com
Sat Feb 8 12:07:27 EST 2020


I tried to play with extract::check() without much success : line 13
crashes !?...
This is a very simple exemple : would like to get it to work. Could
somebody help ? Still googling / searching for a solution

Le ven. 7 févr. 2020 à 22:43, stefan <stefan at seefeld.name> a écrit :

>
> On 2020-02-07 4:06 p.m., HOUSSEN Franck wrote:
>
> With boost python, how to pass a tuple of lists from python to C++ ? Code
> attached : line 12 crashes ?! Googling but no fix for now.
>
> You are referring to this line:
>
>   np::ndarray lsInt = boost::python::extract<np::ndarray>(t[0]);
>
> Note that this line is actually doing two things:
>
> 1) it creates a boost::python::extract<np::ndarray> object
>
> 2) it calls conversion operator on it to convert to np::ndarray
>
> Note that the conversion may fail (for example if the object doesn't
> contain an object of that type). In case of doubt, you may want to call
> extract::check() to see whether it's actually valid.
>
> See
> https://www.boost.org/doc/libs/1_72_0/libs/python/doc/html/reference/to_from_python_type_conversion.html#to_from_python_type_conversion.boost_python_extract_hpp.class_template_extract
> for details.
>
>
>
> [image: Stefan]
>
> --
>
>       ...ich hab' noch einen Koffer in Berlin...
>
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> https://mail.python.org/mailman/listinfo/cplusplus-sig
>


-- 
Bonne journée,

Franck HOUSSEN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20200208/418a3d55/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.png
Type: image/png
Size: 1478 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20200208/418a3d55/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dummy.cpp
Type: text/x-c++src
Size: 1537 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20200208/418a3d55/attachment.cpp>


More information about the Cplusplus-sig mailing list