[C++-sig] python namespace

David Abrahams dave at boost-consulting.com
Wed Nov 20 22:56:10 CET 2002


Francois Ostiguy <ostiguy at fnal.gov> writes:

> So far all my attempts have failed. In particular, I tried the following
> recipe, suggested by Dave in an earlier message
>
> namespace python = boost::python;
>
> void f1() {
>   std:: cout <<"f1" << std::endl;
> }
>
> void f2() {
>   std:: cout <<"f2" << std::endl;
> }
>
>
> 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);
>
>  }


> It fails with the following message:
>
> namespace.cc: In function `void init_module_outer()':
> namespace.cc:29: non-lvalue in unary `&'
> namespace.cc:29: no match for call to `(boost::python::api::object) (
>    boost::python::handle<PyObject>&)'
> /usr/local/ap/include/boost/python/object_core.hpp:101: candidates are:
>    boost::python::api::object
>    boost::python::api::object_operators<U>::operator()() const [with U =
>    boost::python::api::object]
> /usr/local/ap/include/boost/python/object_call.hpp:16:
>    boost::python::detail::dependent<boost::python::api::object, A0>::type
>    boost::python::api::object_operators<U>::operator()(const A0&) const
> [with
>    A0 = boost::python::handle<PyObject>, U = boost::python::api::object]
> namespace.cc:33: non-lvalue in unary `&'

The above looks like it is trying to call some function-call operator
with a handle<> argument. Where do you suppose that's coming from?

-- 
                       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