Re: Wrapping C with Python

2008-08-05 Thread Uwe Schmitt
On 4 Aug., 15:14, brad <[EMAIL PROTECTED]> wrote: > RPM1 wrote: > > ... > > > Basically you just compile your C code as a regular C code dll.  ctypes > > then allows you to access the functions in the dll very easily. > > Does that work with C++ code too or just C? It works if the interface of the

Re: Wrapping C with Python

2008-08-04 Thread Terry Reedy
brad wrote: RPM1 wrote: ... Basically you just compile your C code as a regular C code dll. ctypes then allows you to access the functions in the dll very easily. Does that work with C++ code too or just C? On Windows, You can apparently works either with stdcall or cdecl functions. "cty

Re: Wrapping C with Python

2008-08-04 Thread RPM1
Anish Chapagain wrote: On 4 Aug, 14:14, brad <[EMAIL PROTECTED]> wrote: RPM1 wrote: ... Basically you just compile your C code as a regular C code dll. ctypes then allows you to access the functions in the dll very easily. Does that work with C++ code too or just C? Hi.. I havenot tried..

Re: Wrapping C with Python

2008-08-04 Thread RPM1
brad wrote: RPM1 wrote: ... Basically you just compile your C code as a regular C code dll. ctypes then allows you to access the functions in the dll very easily. Does that work with C++ code too or just C? I believe it does work with C++ although I have not done that. Here's a simple ex

Re: Wrapping C with Python

2008-08-04 Thread Stefan Behnel
Anish Chapagain wrote: > I tried wrapping a simple C code suing SWIG to Python, but am having > problem, Try Cython. It's a Python-like language between Python and C that compiles to C code. It makes it very easy to call into C functions and to hide them behind a nice Python module. http://cython

Re: Wrapping C with Python

2008-08-04 Thread Anish Chapagain
On 4 Aug, 14:14, brad <[EMAIL PROTECTED]> wrote: > RPM1 wrote: > > ... > > > Basically you just compile your C code as a regular C code dll.  ctypes > > then allows you to access the functions in the dll very easily. > > Does that work with C++ code too or just C? Hi.. I havenot tried..before with

Re: Wrapping C with Python

2008-08-04 Thread brad
RPM1 wrote: ... Basically you just compile your C code as a regular C code dll. ctypes then allows you to access the functions in the dll very easily. Does that work with C++ code too or just C? -- http://mail.python.org/mailman/listinfo/python-list

Re: Wrapping C with Python

2008-08-04 Thread RPM1
Anish Chapagain wrote: Hi!! I tried wrapping a simple C code suing SWIG to Python, but am having problem, I am not too familiar with SWIG, (I have looked at it), but you may want to try ctypes in the standard module library. It's very easy to use. I use it on Windows with gcc but I believe

Wrapping C with Python

2008-08-04 Thread Anish Chapagain
Hi!! I tried wrapping a simple C code suing SWIG to Python, but am having problem, my .c file is, Step 1: example.c -- double val=3.0; int fact(int n) { if(n<=1) return 1; else return n*fact(n-1); } int mod(int x, int y) { return (x%y); } Step 2: I then created interface file as. exa