Boost logo

Boost :

From: rwgk_at_[hidden]
Date: 2001-08-16 19:30:57

--- In boost_at_y..., John Hunter <jdhunter_at_a...> wrote:
> I assumed that Ralf's comment regarding member functions "However,
> default arguments are lost at the Python level." would apply to
> constructors as well.

I should have worded this more carefully. What I meant is
that the default arguments are lost at the Python level
if you just wrap the function in the "normal way", e.g.:

class myclass {
     int foo(int i = 123);
py_myclass.def(&myclass::foo, "foo");

From Python you can only call foo with one argument.
If you use the trick

int foo_0(const myclass& mc) { return; }
int foo_1(const myclass& mc, int i) { return; }
py_myclass.def(foo_0, "foo");
py_myclass.def(foo_1, "foo");

you will be able to use foo at the Python level with no
arguments and with one argument.

Does this make things clearer?


Boost list run by bdawes at, gregod at, cpdaniel at, john at