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:
@@ -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)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user