[C++-sig] How argument passing works with boost python ?

cbailly b.christophe at yahoo.fr
Tue Aug 15 13:49:27 CEST 2006


Thanks for your answer

Can you tell me if my understanding is ok:

Does it mean that each time a str python object is passed as an argument,  
then an automatic conversion is made to std::string type ? Regardless of  
the prototype of the method, just because converters have been registered.

str object -> alway converted to std::string ?
If a dict object is passed, no conversion is made ?

Sorry, it is still a bit confusing...

Chris



Le Tue, 15 Aug 2006 12:26:05 +0200, Roman Yakovenko  
<roman.yakovenko at gmail.com> a écrit:

> On 8/15/06, cbailly <b.christophe at yahoo.fr> wrote:
>> Hi,
>>
>>     I have read tutorials/FAQS about boost python but still, I do not
>> understand how arguments are passed and converted (automatically ?) to  
>> the
>> C++ types... since the profile of the methods are not declared.
>>
>> For instance, in the Hello world example (from the tutorial)
>>
>> BOOST_PYTHON_MODULE(hello)
>> {
>>      class_<World>("World")
>>          .def("greet", &World::greet)
>>          .def("set", &World::set)
>>      ;
>> }
>>
>> "set" method takes a std::string argument (not declared). This is  
>> really a
>> mystery...  Is the std::string type compatible with the str type ? Where
>> is the conversion made ?. What if the method set takes std::string &
>> parameter instead ?
>
> This link http://boost.org/libs/python/doc/v2/faq.html#custom_string
> will help you to
> understand what is going on in this specific case.
>



-- 
Utilisant le client e-mail révolutionnaire d'Opera :  
http://www.opera.com/mail/




More information about the Cplusplus-sig mailing list