Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #11450

Re: Help needed with using SWIG wrapped code in Python

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'subject:using': 0.04; 'predefined': 0.05; 'subject:Python': 0.06; 'initialize': 0.07; 'subject:code': 0.07; 'wrapper': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'wrappers': 0.09; 'c++': 0.12; 'skip:[ 20': 0.12; 'def': 0.15; 'library': 0.15; 'argument': 0.15; '*args)': 0.16; '*args):': 0.16; 'char**': 0.16; 'fit,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'language,': 0.17; 'subject:Help': 0.17; '>>>': 0.18; 'programming': 0.20; '(like': 0.21; '(most': 0.21; 'header:In- Reply-To:1': 0.22; 'faster,': 0.23; 'traceback': 0.24; 'skip:b 20': 0.26; 'handled': 0.28; 'received:84': 0.28; 'problem': 0.28; 'import': 0.28; 'importing': 0.29; 'stefan': 0.29; 'basically,': 0.30; 'typeerror:': 0.30; "skip:' 10": 0.30; 'error': 0.32; 'does': 0.32; 'comment': 0.32; 'it.': 0.33; "can't": 0.33; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.34; 'last):': 0.34; 'header:X-Complaints-To:1': 0.35; 'file': 0.36; 'problems': 0.36; 'skip:" 10': 0.36; 'facing': 0.37; 'instead.': 0.37; 'things,': 0.37; 'using': 0.37; 'but': 0.37; 'received:org': 0.38; 'easier': 0.38; 'subject:: ': 0.39; 'flexibility': 0.39; 'ways': 0.39; 'header:Mime-Version:1': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'case': 0.39; "it's": 0.40; 'more': 0.60; 'your': 0.61; 'power': 0.63; 'full': 0.63; 'special': 0.67; 'automatic': 0.72; 'hand,': 0.76
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Help needed with using SWIG wrapped code in Python
Date Mon, 15 Aug 2011 12:08:02 +0200
References <CANMJH-sXPQoNz9OYm1kJFJzZG8cXcMPdPd=wTPSwvpFVaTrwGQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-084-056-020-031.pools.arcor-ip.net
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11
In-Reply-To <CANMJH-sXPQoNz9OYm1kJFJzZG8cXcMPdPd=wTPSwvpFVaTrwGQ@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7.1313402896.27778.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1313402896 news.xs4all.nl 23933 [2001:888:2000:d::a6]:57438
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11450

Show key headers only | View raw


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 "pyossimtest.py", 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.

Stefan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Help needed with using SWIG wrapped code in Python Stefan Behnel <stefan_ml@behnel.de> - 2011-08-15 12:08 +0200

csiph-web