[C++-sig] Adding a method on the fly

Kelly Burkhart kelly at kkcsm.net
Wed Apr 5 06:29:52 CEST 2006

Is it possible to add a method to an object on the fly?  Something like:

// Add a method 'foo' to object
void addMethod( object obj )
    call_method<void>(obj.ptr(),"__setattr__", "foo", "lambda x:x+x" );

The "lambda..." string would have to get evaluated by Python to return an
appropriate object to bind to foo.  Is there any way to do something like


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060404/c06b0f4f/attachment.htm>

More information about the Cplusplus-sig mailing list