logo       

Re: Re: instantiating python objects within C++: msg#00305

python.c++

Subject: Re: Re: instantiating python objects within C++

David Abrahams wrote:

I don't see what Sandbox being a type or a module has to do with it.
A Python type is just a kind of Python object. When the class_< ... >
instantiation creates it, it holds onto it as well.

I see. My misunderstanding was that I thought the type would really
contain the scope, i.e. 'Sandbox.Base' wouldn't be the same type as
'Foobar.Base'. That's why I assumed the scope being a type would make
a difference.

Of course it is, the way you've written it. You can always keep a
python::object 'save_base_type' around and assign into it:

save_base_type = base_type;

A more-elegant way to hang onto it is:

python::object base_type;
BOOST_PYTHON_MODULE(Sandbox)
{
base_type
= python::class_<Base>("Base")
.def(...)
...
;
}

cool. Again, I thought that this wasn't possible or else Sandbox.Base
would have to be the same as Foobar.Base. But if python doesn't care
for the scope itself when determining the type it's indeed the same.

Thanks a lot !

I'll try to get some remaining things straightened out, then I'll
see whether I can submit some examples for the tutorial.

Regards,
Stefan


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise