Help needed with using SWIG wrapped code in Python

Stefan Behnel stefan_ml at
Mon Aug 15 12:08:02 CEST 2011

Vipul Raheja, 15.08.2011 10:08:
> I have wrapped a library from C++ to Python using SWIG. But I am facing
> problems while importing and using it in Python.
> $ python
> >>> import pyossimtest
> >>> import pyossim
> >>> a = ["Image1.png","Image2.png"]
> >>> b = pyossimtest.Info()
> >>> b.initialize(len(a),a)
> Traceback (most recent call last):
>    File "<stdin>", line 1, in<module>
>    File "", line 84, in initialize
>      def initialize(self, *args): return _pyossimtest.Info_initialize(self,
> *args)
> TypeError: in method 'Info_initialize', argument 3 of type 'char *[]'
> What does this error message imply? I have already handled char** as a
> special case in swig using typemaps.

I have little experience with SWIG, so I can't comment much on the problem 
at hand, but what I can do is to encourage you to use Cython instead. It's 
faster, easier to use and much more versatile for writing Python wrappers 
than SWIG. Basically, it provides you with the full power and flexibility 
of a programming language, whereas SWIG (like all automatic wrapper 
generators) is always limiting because it has its predefined ways of 
wrapping things, and if they don't fit, you're on your own fighting up-hill 
against it.


More information about the Python-list mailing list