[C++-sig] python namespace

David Abrahams dave at boost-consulting.com
Wed Nov 20 23:29:57 CET 2002


Francois Ostiguy <ostiguy at fnal.gov> writes:

>> > BOOST_PYTHON_MODULE(outer)
>> > {
>> >
>> >
>> >   python::handle<> inner_module1( PyModule_New("outer.inner1"));
>> >   python::scope inner_scope1 =  object(inner_module1);
>> don't you need `python::' here?--^
>> >
>> >   python::def("f1", &f1);
>> >
>> >   python::handle<> inner_module2( PyModule_New("outer.inner2"));
>> >   python::scope inner_scope2 =  object(inner_module2);
>> don't you need `python::' here?--^
>> >
>> >   python::def("f2", &f2);
>> >
>> >  }
>
> Dave -
>
> you are correct. I forgot to use python::object instead of object in
> this version of my simplified example. I tried many permutations
> and I used the the wrong one in my post.
>
> The corrected version still does not compile:
>
> /usr/local/ap/include/boost/utility.hpp: In copy constructor
>    `boost::python::scope::scope(const boost::python::scope&)':
> /usr/local/ap/include/boost/utility.hpp:55: `
>    boost::noncopyable::noncopyable(const boost::noncopyable&)' is private
> namespace.cc:29: within this context
> namespace.cc: In function `void init_module_outer()':
> namespace.cc:29:   initializing temporary from result of `
>    boost::python::scope::scope(const boost::python::api::object&)'
> gmake: *** [namespace.o] Error 1

Have you taken a close look at the error messages and the
documentation for scope at
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/v2/scope.html#scope-spec
?
They tell all. 

   python::scope inner_scope1(object(inner_module1));

Hmm, I probably should make the scope constructor explicit.


-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list