logo       

Re: newbie: loading' example' example in python: msg#00116

programming.swig

Subject: Re: newbie: loading' example' example in python

Hmm - I see this now browsing the 'example.py' file that was generated.

...and you have to invoke it as:

$ python -i example.py

and only then you have access to the functions via their original names (which is very convenient) but where is this documented? the docs, which I reviewed several times imply that this is NOT the way to do it (and make no mention of the way you suggest).

The docs say
<quote>
$python
>>> import example
>>> example.fact(4)
24
>>>
</quote>

and make no mention at all of the correct way to use it. Tho the chapter does note that it is under repair...

And several hours of googling for the answer did not reveal the answer either, tho now it might...:)

Anyway, things look considerably clearer and I am amazed at Swig's ingenuity.

thanks for your help!

Harry


Nicholas Henke wrote:
On Thu, 23 Jan 2003 17:55:17 -0800
Harry Mangalam <hjm@xxxxxxxxx> wrote:

> OK - with the help of my betters (thanks to Diane Trout), I've been able
> to get > the C module to load, but the solution is not like anything the recent
> docs > indicate.
> > You have to name the generated .so '_example.so' and in Python:
> > >>>import _example
> > No other combination of names, underscores, etc worked. If this is in
> fact the > case, it might be worth correcting the docs for this. However, it seems
> odd > that this convention is actually the intended one (...?)

That is only if you want to import the shared lib directly. SWIG assumes that
you will access the wrapper through the generated python code. You should see an
example.py where you compiled the extention. This is what gets imported if you
do an 'import example', and in example.py you will see 'import _example'.


Nic

--
Cheers, Harry
Harry J Mangalam - 949 856 2847 (v&f) - hjm@xxxxxxxxx
<<plain text preferred>>

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise