Re: PyArg_ParseTupleAndKeywords

2010-01-23 Thread Mr.M
MRAB ha scritto: I think you're right. I have rewritten my code, a piece at a time, and (and this is very annoying) now it works fine. I really can't understand what went wrong with my old code. Luca. -- http://mail.python.org/mailman/listinfo/python-list

Re: PyArg_ParseTupleAndKeywords

2010-01-23 Thread MRAB
Mr.M wrote: MRAB ha scritto: Did you specify that the method accepts keywords arguments with METH_KEYWORDS? The function would take parameters for the instance (self), the positional arguments (args) and the keyword arguments (kwargs). http://docs.python.org/c-api/structures.html If you don't

Re: PyArg_ParseTupleAndKeywords

2010-01-23 Thread Mr.M
MRAB ha scritto: Did you specify that the method accepts keywords arguments with METH_KEYWORDS? The function would take parameters for the instance (self), the positional arguments (args) and the keyword arguments (kwargs). http://docs.python.org/c-api/structures.html If you don't use METH_KEY

Re: PyArg_ParseTupleAndKeywords

2010-01-23 Thread MRAB
_text = "text for free_text") ok, every time the code fails i get this exception: TypeError: expected string or Unicode object, tuple found so, i think for some reason PyArg_ParseTupleAndKeywords receives "args" as a touple instead of something else. This is ever

Re: PyArg_ParseTupleAndKeywords

2010-01-23 Thread Mr.M
ot;text for free_text") ok, every time the code fails i get this exception: TypeError: expected string or Unicode object, tuple found so, i think for some reason PyArg_ParseTupleAndKeywords receives "args" as a touple instead of something else. This is ever

Re: PyArg_ParseTupleAndKeywords

2010-01-22 Thread Carl Banks
   "end_time", >                                "storage_time", >                                "flags", >                                "bytes_sent", >                                "bytes_received", &g

PyArg_ParseTupleAndKeywords

2010-01-22 Thread Mr.M
"end_time", "storage_time", "flags", "bytes_sent", "bytes_received",

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-21 Thread Gabriel Genellina
"b", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a, &b)) return NULL; return Py_BuildValue("(CC)", a, b); } It's not related to default values. foo(x=30) should raise an error; the allowed parameter names are only

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-19 Thread Joachim Dahl
My mistake seems to be that I declared char a, b; instead of int a, b; Thank you for sorting this out. Joachim -- http://mail.python.org/mailman/listinfo/python-list

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-19 Thread Emeka
Okay if that is the case, why do we need it? By having int a = 65, b = 66 , why should we also have *kwlist[]? static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds) { int a=65, b=66; char *kwlist[] = {"a", "b", NULL}; if (!PyArg_ParseTupleAndKeywor

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-18 Thread casevh
On Dec 18, 10:28 am, Joachim Dahl wrote: > My mistake seems to be that I declared > > char a, b; > > instead of > > int a, b; > > Thank you for sorting this out. > > Joachim I think you need to initialize them, too. -- http://mail.python.org/mailman/listinfo/python-list

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-18 Thread Case Vanhorsen
>> >> On Fri, Dec 18, 2009 at 2:26 AM, Emeka wrote: >> >    char *kwlist[] = {"a", "b", NULL}; >> >    if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a, >> > &b)) >> > I am yet to understand

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-18 Thread Emeka
, 2009 at 3:02 PM, Case Vanhorsen wrote: > On Fri, Dec 18, 2009 at 2:26 AM, Emeka wrote: > > char *kwlist[] = {"a", "b", NULL}; > >if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a, > > &b)) > > I am yet to underst

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-18 Thread Case Vanhorsen
On Fri, Dec 18, 2009 at 2:26 AM, Emeka wrote: >    char *kwlist[] = {"a", "b", NULL}; >    if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a, > &b)) > I am yet to understand what pointer kwlist[] does and why it is needed? > Rega

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-18 Thread Emeka
char *kwlist[] = {"a", "b", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a, &b)) I am yet to understand what pointer kwlist[] does and why it is needed? Regards, Emeka On Fri, Dec 18, 2009 at 8:17 AM, casevh wrote: >

Fwd: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-18 Thread Emeka
static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds) { int a=65, b=66; char *kwlist[] = {"a", "b", NULL}; I am yet to understand what kwlist pointer does and why it is needed? if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlis

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-18 Thread casevh
e it may have had.  In other words, the optional character > arguments > that are skipped seem to be nulled by PyArg_ParseTupleAndKeywords(). The following code seems to work fine for me: static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds) { int a=6

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-17 Thread Joachim Dahl
kipped seem to be nulled by PyArg_ParseTupleAndKeywords(). -- http://mail.python.org/mailman/listinfo/python-list

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-12-01 Thread Joachim Dahl
code > > > static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds) > > { > >   char a, b; > >   char *kwlist[] = {"a", "b", NULL}; > >   if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a, > > &b)) &g

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-11-30 Thread casevh
wlist[] = {"a", "b", NULL}; >   if (!PyArg_ParseTupleAndKeywords(args, kwrds, "|CC", kwlist, &a, > &b)) >     return NULL; >   ... > > then the following works: > > >>> foo('a') > >>> foo('a','b&#x

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-11-30 Thread Joachim Dahl
I think that "C" encoding is what I need, however I run into an odd problem. If I use the following C code static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds) { char a, b; char *kwlist[] = {"a", "b", NULL}; if (!PyArg_ParseTupleAndKeywords(

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-11-30 Thread casevh
"foochar", NULL}; >   if (!PyArg_ParseTupleAndKeywords(args, kwrds, "c", kwlist, > &foochar)) >     return NULL; >   ... > > The question remains the same: why can't I pass a single character > argument to this function under Python3.1? > > Thanks

Re: PyArg_ParseTupleAndKeywords in Python3.1

2009-11-30 Thread Joachim Dahl
Obviously the name of the C function and the char variable cannot both be foo, so the C code should be: static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds) { char foochar; char *kwlist[] = {"foochar", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwrds, &

PyArg_ParseTupleAndKeywords in Python3.1

2009-11-30 Thread Joachim Dahl
gs, PyObject *kwrds) { char foo; char *kwlist[] = {"foo", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwrds, "c", kwlist, &foo)) return NULL; ... In Python3.0 this also works, but in Python3.1 I get the following error: TypeError: argument 1 must be a byte st

Re: documentation for PyArg_ParseTupleAndKeywords

2004-11-30 Thread Scott David Daniels
Steven Bethard wrote: Thanks for the pointers. What's the "doco gadget" you're talking about? I conclude from this question that you are not using a Windows python. I suspect, therefore, the answer is Gilda Ratner's " Never mind." --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.o

Re: documentation for PyArg_ParseTupleAndKeywords

2004-11-30 Thread Steven Bethard
John Machin wrote: Well I just fired up the doco gadget and pasted "PyArg_ParseTupleAndKeywords" into the Search box and the 2nd reference it came up with was this: manual: Python/C API Reference Manual section: 5.5 Parsing arguments and building values The 1st, 3rd & 4th r

Re: documentation for PyArg_ParseTupleAndKeywords

2004-11-30 Thread John Machin
me to the documentation on how > PyArg_ParseTupleAndKeywords, etc. work? In particular, I can't figure > out how the format arg to vgetargskeywords should be specified... > Well I just fired up the doco gadget and pasted "PyArg_ParseTupleAndKeywords" into the Search box and the 2nd re

Re: documentation for PyArg_ParseTupleAndKeywords

2004-11-30 Thread Pierre Barbier de Reuille
Steven Bethard a écrit : I'm just starting to play around with the Python source. (Specifically, I'm looking at adding a key argument to max/min like sorted has.) Can anyone direct me to the documentation on how PyArg_ParseTupleAndKeywords, etc. work? In particular, I can't

documentation for PyArg_ParseTupleAndKeywords

2004-11-29 Thread Steven Bethard
I'm just starting to play around with the Python source. (Specifically, I'm looking at adding a key argument to max/min like sorted has.) Can anyone direct me to the documentation on how PyArg_ParseTupleAndKeywords, etc. work? In particular, I can't figure out how th