|
|
Boost.PythonHeader <boost/python/scope.hpp> |
scopescope
synopsisscope
constructors and destructorDefines facilities for querying and controlling the Python scope (namespace) which will contain new wrapped classes and functions.
scopeThe scope class has an associated global Python object
which controls the Python namespace in which new extension classes and
wrapped functions will be defined as attributes. Default-constructing a
new scope object binds that object to the associated Python
object. Constructing a is associated with , and
scope
synopsis
namespace boost { namespace python
{
class scope : public object, private noncopyable
{
public:
scope(object const&);
scope();
~scope()
};
}}
scope constructors
and destructorscope(object const& x);Stores a reference to the current associated scope object, and sets the associated scope object to the one referred to by
x.ptr().
The object base class is initialized with x.
scope();Stores a reference to the current associated scope object. The
object base class is initialized with the current associated
scope object. Outside any module initialization function, the current
associated Python object is None.
~scope()Sets the current associated Python object to the stored object.
C++ Module definition:
#include <boost/python/class.hpp>
#include <boost/python/scope.hpp>
using namespace boost::python;
struct X
{
void f();
struct Y { int g() { return 0; } };
};
BOOST_PYTHON_MODULE(nested)
{
scope outer
= class_<X>("X")
.def("f", &X::f)
;
class_<Y>("Y")
.def("g", &Y::g)
;
}
Interactive Python:
>>> import nested >>> y = nested.X.Y() >>> y.g() 0
Revised 03 October, 2002
© Copyright Dave Abrahams 2002. All Rights Reserved.