[C++-sig] constructing Python objects in C++

Andrew Straw strawman at astraw.com
Wed Jul 7 23:07:10 CEST 2004

(Thanks much for providing guidance on previous questions. On with a 
simple? newbie question.)

The tutorial (section "Derived Object types") nicely explains that 
class_<T> lets me make a Python object out of a C++ class. 

However, if I've already defined class_<T> once in my 
BOOST_PYTHON_MODULE block, how can I create a Python object of this 
wrapped class elsewhere in the code without the class_<T> block? 

In other words, right now, I'm forced to replicate the class_<T> 
definition in both the BOOST_PYTHON_MODULE block and also whereever I 
want to create a Python object representing an instance of this class.  
Is there a way to avoid such multiple definitions?

(I feel that maybe I'm missing something pretty fundamental...)

Cheers and TIA,

More information about the Cplusplus-sig mailing list