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

David Abrahams dave at boost-consulting.com
Fri Dec 3 09:02:21 CET 2004


Garrick Meeker wrote:

 > 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>),

You must mean raw_function(&MyClass::init).  Yes, you can do that
if MyClass::init is a static member function:

     void MyClass::init(tuple args, dict kw)

Be aware that the first element of args will be the "self"
object and it will be uninitialized, just as in Python.  So
you'll need to pass those arguments on to some other wrapped
constructor.  See the enclosed for an example


-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: raw_ctor.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041203/55497c8f/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: raw_ctor.py
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041203/55497c8f/attachment-0001.txt>


More information about the Cplusplus-sig mailing list