Boost.Python constructor with optional arguments

Viewed 2512

I want to use Boost.Python to create a Python wrapper for a C++ constructor with optional arguments. I want the Python wrapper to act like this:

class Foo():
  def __init__(self, filename, phase, stages=None, level=0):
    """
    filename -- string
    phase -- int
    stages -- optional list of strings
    level -- optional int
    """
    if stages is None:
      stages = []
    # ...

How do I do this with Boost.Python? I don't see how to do it with make_constructor, and I don't know how to make a constructor with raw_function. Is there some better documentation than this out there?

My specific problem is trying to add two optional arguments (stages and level) to these two constructors:

https://github.com/BVLC/caffe/blob/rc3/python/caffe/_caffe.cpp#L76-L96

1 Answers
Related