ctypes: pointer to method

Martin Landa landa.martin at gmail.com
Thu Aug 5 19:50:21 CEST 2010


Hi,

is it possible to pass pointer to a method using ctypes. Sample code:

    ...
    G_set_error_routine(byref(self._print_error))
    ...

    def _print_error(self, msg, type):
        """!Redirect stderr"""
        self.log.write(msg)

gives me

    G_set_error_routine(byref(self._print_error))
TypeError: byref() argument must be a ctypes instance, not
'instancemethod'


C function G_set_error_routine is defined as

void G_set_error_routine(int (*error_routine) (const char *, int))

Thanks in advance for any pointers. Martin



More information about the Python-list mailing list