tags:

views:

70

answers:

1

Hi, I tried loading C shared library .so in Python using ctypes.CDLL class (Linux). Here is the link to which tells what I did. As I see the documentation it says CDLL class assumes that function returns int types. I've a doubt here what if I need to return variable of type other than the int type from a function in C?. And to what extent we can use C functions in Python i mean what are the limits/restrictions on using C shared libraries and functions

Thanks in Advance

+4  A: 

By default, it assumes int, but you can set restype to any of the supported types to override that. E.g., from the docs:

strchr.restype = c_char_p

This means that strchr returns a pointer to a char, which corresponds to a Python string (or None, for a NULL pointer).

Matthew Flaschen
Thanks Matthew that clears my one doubt about return type
Vasudev
If Matt's response answered your question, please accept the answer.
Rakis