on Mon Apr 16 2012, John Reid <j.reid-AT-mail.cryst.bbk.ac.uk> wrote:
> On 15/04/12 03:23, Dave Abrahams wrote:
>>
>> You can't do this; don't even try. Each C++ class has to have a unique
>> Python identity. If you just want to refer to the same class by a
>> different name, you can of course:
>>
>
>> BOOST_PYTHON_MODULE( _sandbox )
>> {
>> namespace bp = ::boost::python;
>> object inner;
>> {
>> bp::scope scope = bp::class_< Outer1>( "Outer1" );
>> inner = bp::class_< Inner>( "Inner" );
>> }
>>
>> {
>> object outer2 = bp::class_< Outer2>( "Outer2" );
>> outer2.attr("Inner") = inner;
>> }
>> }
>>
>
> I didn't know you could do that and it is useful but it is not quite
> what I had in mind. I would rather not pass the inner object around
> all the parts of my code that might need it. Is it possible to get it
> out of the registry in the second block?
Why don't you read to the end of my posting? The answer's there at the
bottom :-)
--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig