I'd like to be able to use PyArg_ParseTuple() in a generic way.

for example, i'd like to have all commands start with 1 integer parameter, and 
this "commandID" will inform me of what parameters come next (via LUT).

knowing that i can then call ParseTuple again with the proper parameters.

like this:

if (PyArg_ParseTuple(args, "i|", &commandID)) {

        switch (commandID) {
        
                case cmd_with_str: {
                        const char *strZ = NULL;
                        
                        if (PyArg_ParseTuple(args, "is", &commandID, &strZ)) {
                                //      do something with string
                        }
                        break;
                }
        
                case cmd_with_float: {
                        float   valF = -1;
                        
                        if (PyArg_ParseTuple(args, "if", &commandID, &valF)) {
                                //      do something with float
                        }
                        break;
                }
        }
}

is there a way to achieve this?  the "i|" at the start is not working
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to