passing callback function to c-extension

Skip Montanaro skip at
Wed Jan 14 18:02:17 CET 2004

    Diez> I'm now looking for a way to ensure that the passed object is
    Diez> actually a callable one 

Try it and see.  If an exception is raised, just return NULL.  The
appropriate exception stuff will have been set.

Alternatively, you can test the value of


to see if obj is really callable and do your own error recovery.

    - and how to throw exceptions. 

The C API manual is your friend here:

Search for "exception".


More information about the Python-list mailing list