Skip to content

Commit 51487a7

Browse files
author
Ralf W. Grosse-Kunstleve
committed
exercise keyword argument support
[SVN r24389]
1 parent 500b8e1 commit 51487a7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

test/injected.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <memory>
1111
#include <boost/shared_ptr.hpp>
1212
#include <boost/python/make_constructor.hpp>
13+
#include <boost/python/args.hpp>
1314

1415
using namespace boost::python;
1516

@@ -29,7 +30,11 @@ BOOST_PYTHON_MODULE(injected_ext)
2930
class_<X>("X", init<int>())
3031
.def("__init__", make_constructor(empty))
3132
.def("__init__", make_constructor(sum))
32-
.def("__init__", make_constructor(product), "this is product's docstring")
33+
.def("__init__", make_constructor(product
34+
, default_call_policies()
35+
, ( arg_("a"), arg_("b"), arg_("c"))
36+
),
37+
"this is product's docstring")
3338
.def("value", &X::value)
3439
;
3540
}

test/injected.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>>> from injected_ext import *
66
>>> X(3,5).value() - (3+5)
77
0
8-
>>> X(3,5,7).value() - (3*5*7)
8+
>>> X(a=3,b=5,c=7).value() - (3*5*7)
99
0
1010
>>> X().value()
1111
1000

0 commit comments

Comments
 (0)