logo       

naive question about passing in a NULL via Python: msg#00179

programming.swig

Subject: naive question about passing in a NULL via Python

Hello,

I apologize if the answer to my question is readily available. I have
looked at the 1.3 development documentation but I have not found what
I need.

I am using SWIG 1.3.17 and Python 2.2.2.

Suppose I have this simple C function declaration:

void myfunc(char *mystring);

The code has one branch if mystring points to a standard
null-terminated string, but follows a different branch if mystring is
(the usual C) NULL, ie.

if ( mystring == NULL ){ do something;}
else { do different;}

What is the most "elegant", "easy" and "proper SWIG" way to have this
function wrapped so that in Python I can simply do

import mymodule
mymodule.myfunc(<something>)

and have the C code called with mystring == NULL?

I think it would be "natural" to call in Python

mymodule.myfunc(None)

and have the None be passed to the C as a NULL. Is there a
straightforward way to do that?

Thank you for your time.

Scott
_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise