[C++-sig] Re: bypassing boost::python's keyword handling

Garrick Meeker gmeeker at ilm.com
Fri Dec 3 01:18:13 CET 2004


Oh, I didn't see that.  I would like to use this for a python class 
__init__ method, but I'm not sure how this interacts with the init<> 
stuff.  Since __init__ is always defined, can I just add def("__init__", 
raw_pointer<&MyClass::init>), or can I have a C++ constructor that takes 
PyObject arg and keyword arguments?

Garrick Meeker wrote:
 >/ Is it possible to use boost to wrap a function that expects args and
/>/ keywords as two PyObject's? This is old C-style Python code that could
/>/ be written but the python syntax must be the same. Imagine I'm
/>/ implementing some sort of dictionary class in C++. The easiest way
/>/ might be to wrap this in python, so this may be purely an academic
/>/ question. Something like:
/>/
/>/ void f(PyObject *args, PyObject *kw);
/>/ def("f_base", &f);
/>/
/>/ def f(*args, **kw):
/>/ f_base(args, kw)
/>/
/>/ f(a=1, b=2, c=3)
/
Does
http://www.boost.org/libs/python/doc/v2/raw_function.html
help?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com





More information about the Cplusplus-sig mailing list