[C++-sig] Re: instantiating python objects within C++

Stefan Seefeld seefeld at sympatico.ca
Mon May 26 19:10:31 CEST 2003


Hi David,

David Abrahams wrote:

>     object FooClass
>         = class_<Foo>("Foo", init<int, char const*>())
>                .def( ... )
>                ...
>                ;
> 
>     object foo = FooClass(3, "hello");
> 
> Joel, we might want to do that example in two steps as shown above
> just to make it crystal clear what's happening.

yes, the 'missing link' was that I didn't understand what the above
really meant for the python interpreter. For example right now I'm
not even instantiating that class explicitely, I use a callable's
'()' operator. The python interpreter then figures out that it should
create the so defined wrapper object and wrap it around my existing
foo instance.
That is something I didn't understand (and still don't in detail).
Explaining that in greater detail would surely help, not only to
use boost.python, but also to understand how all the magic works.

Thanks,
		Stefan








More information about the Cplusplus-sig mailing list