PyArg_ParseTuple() and oprtional remaining argument lists

phil phil at ricochet.net
Mon Nov 29 08:37:32 CET 1999


Hi,

i've developed an extension .dll in C for a Window's based system and
it works really well. However, i wanted to add a function that took a
second optional argument so wrote the following:

...blah...
	if (PyArg_ParseTuple(args,"s|s",&name,&show)) {
		// happy things.

and it seems to return 0 if only one parameter is supplied, yet is
happy with two. It's not a major inconvenience as i can just document
it as requiring two parameters, but i'd like to know what i'm doing
wrong here. I also have trouble using PyArg_ParseTuple(...) with a
single item, e.g.
	if (PyArg_Parse(args,"i",&index) && (index >= 0)) {
is ok, but
	if (PyArg_ParseTuple(args,"i",&index) && (index >= 0)) {
fails. Again not a major problem, i'm more concerned that i'm doing
something wrong that will bite me later (this was cut and pasted from
my code, so the syntax may be a little suspect...)

The documentation shows examples of the above working correctly. I'm
using 1.52. I'm sure it's something silly.

Gracias  Mi Llama es su Llama.

phil.

The world is divided into two sorts of people: those that think the
world is divided into two sorts of people and those that don't.




More information about the Python-list mailing list