[C++-sig] Re: to_python (by-value) converter

David Abrahams dave at boost-consulting.com
Fri Sep 12 17:57:07 CEST 2003


Simon Ouellet <simon.ouellet at orthosoft.ca> writes:

>> 
>> Try executing class_<CppDerived>("CppDerived"); before then.
>> 
>
> Ok I make it work, but that lead me to another question.
>
>
>
> When I put 
>
> class_<CppDerived>("CppDerived"); 
>
> in the module definition. Like this
>
> BOOST_PYTHON_MODULE(embedded_hello)
> {
>     python::class_<Base, BaseWrap, boost::noncopyable>("Base")
>         ;
>     python::class_<CppDerived>("CppDerived")
>        .def("hello", &CppDerived::hello);
> }
>
>
> It didn't work but if I put it before I use the conversion like this:
>     python::class_<CppDerived>("CppDerived")
>        .def("hello", &CppDerived::hello);
>     CppDerived b;    
>
> It work.
>
> It is a scope issue? What I'm missing?

Conversions are registered dynamically.  Constructing
class_<CppDerived> also registers the conversion for C++ CppDerived
objects -> Python.


-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list