title: How to wrap a C++ factory method in a Python __init__ function using SWIG
body: <p>I'm porting a Python extension module written in C++ from Boost.Python to SWIG.</p>
  
  <p>The C++ code defines an abstract class <code>X</code> with a static factory method</p>
  
  <pre><code>class X {
  public:
      static X* create(const char* descr);
      ...
  };
  </code></pre>
  
  <p>The factory method returns a pointer to an instance of some derived class.</p>
  
  <p>With Boost.Python you can wrap the C++ class <code>X</code> in a Python class <code>X</code> that has an </p>
  
  <pre><code>__init__(self, descr)
  </code></pre>
  
  <p>method that calls <code>X::create</code>. In fact, it is done as follows:</p>
  
  <pre><code>namespace bp = boost::python;
  
  bp::class_&lt;X&gt;("X", boost::no_init)
      .def("__init__", bp::make_constructor(&amp;X::create))
      ...
  </code></pre>
  
  <p>Is there a way of doing the same thing with SWIG?</p>