471,330 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Calling python method from C++

Hi All,

I am a newbie to Python programming. I am interfacing python program with c++ shared object library using swig and
facing a problem with callback methods.

C++ method : file1.h
class abc
{
public:
abc();
void Initabc( int (*funptr) ( char * ) );
~abc();
};

file1.cpp calls the assigned function in Initabc.

Python Program : a.py

import abc

msg = ' '
def notify( msg )
print msg
return 0

obj = abc.abc();
obj.Initabc( notify )
.....
.....



The python exits with the following error msg :

TypeError: in method 'abc_Initabc', arg2 of type 'int (*)(char *)'

Anybody can help me in this regard?

Thanks
Oct 26 '07 #1
0 910

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Steven Bethard | last post: by
11 posts views Thread by Kamilche | last post: by
1 post views Thread by Stephen Kellett | last post: by
1 post views Thread by Gerald Klix | last post: by
10 posts views Thread by Max Yuzhakov | last post: by
4 posts views Thread by Edwin Gomez | last post: by
4 posts views Thread by Pyenos | last post: by
10 posts views Thread by Finger.Octopus | last post: by
reply views Thread by Emile van Sebille | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.