2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-21 05:02:17 +00:00

exercise keyword argument support

[SVN r24389]
This commit is contained in:
Ralf W. Grosse-Kunstleve
2004-08-10 17:05:24 +00:00
parent 500b8e190d
commit 51487a75e9
2 changed files with 7 additions and 2 deletions

View File

@@ -10,6 +10,7 @@
#include <memory>
#include <boost/shared_ptr.hpp>
#include <boost/python/make_constructor.hpp>
#include <boost/python/args.hpp>
using namespace boost::python;
@@ -29,7 +30,11 @@ BOOST_PYTHON_MODULE(injected_ext)
class_<X>("X", init<int>())
.def("__init__", make_constructor(empty))
.def("__init__", make_constructor(sum))
.def("__init__", make_constructor(product), "this is product's docstring")
.def("__init__", make_constructor(product
, default_call_policies()
, ( arg_("a"), arg_("b"), arg_("c"))
),
"this is product's docstring")
.def("value", &X::value)
;
}

View File

@@ -5,7 +5,7 @@
>>> from injected_ext import *
>>> X(3,5).value() - (3+5)
0
>>> X(3,5,7).value() - (3*5*7)
>>> X(a=3,b=5,c=7).value() - (3*5*7)
0
>>> X().value()
1000