Mr.M mrm at unknown.nospam
Sat Jan 23 00:23:20 CET 2010


i can't understand what i'm doing wrong. I have a c/api that implements 
a new class.
In (initproc) function i have somethink like this:


(some declarations omitted here)
static char* keywordlist[] = {"service",

if (!PyArg_ParseTupleAndKeywords(args, keywords, "|ssssssiiiiii", 
                                &bytes_received)) return -1;


Ok, what i want is something like this:

import mymodule
a = mymodule.myclass() # ok, this works
a = mymodule.myclass(flags = 1) # bad, this won't work
 > TypeError: expected string or Unicode object, tuple found

I found that if i write this everything works fine:

import mymodule
a = mymodule.myclass(service = "blabla", event_type = "event", free_text 
  = "free", group_uid = "group", remote_name = "remote name", 
remote_abook_uid = "abook", start_time = 1, end_time = 61, storage_time 
= 61, flags = 2)

in other words, the code only works if *EVERY* argument is specified in 
exactly the same position it appears in keyword-null-terminated array.

Could you please help me?

Thank you,


More information about the Python-list mailing list