[C++-sig] Problem injecting Python __init__ into wrapped C++ class

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Wed May 2 02:04:37 CEST 2007


> I have been able to get this to work for ordinary methods, but I would

> like to define an __init__ method in Python for a wrapped C++ class.  I
> have created a test case, following the methods in the Tutorial, that
> demonstrates the runtime error that results when I try this.



I'm doing it with a Python wrapper function for the constructor, e.g. sticking to my

histogram example (although the following is completely made up):



def histogram(a, b, c):

  if (c is None):

     return ext.histogram(a, b)

  return ext.histogram(a, b, c)



The disadvantage is that help(histogram) only reports the function, not the entire class

(in all our modules histogram is ext.histogram until overridden somehow).



I don't really like this solution, but I'm having difficulties imagining something more slick.



Ralf







__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070501/676165ad/attachment.htm>


More information about the Cplusplus-sig mailing list