Re: C API with *args and **kw

2008-10-14 Thread Miki
> Miki <[EMAIL PROTECTED]> writes: > > However when running the test: > > from kw import kw > > kw(default="2") > > kw(1) > > kw() > > > I get "bus error" on the 2'nd call (OS X Python 2.5.2). > > When called without keywords, kwds is NULL.  You need to handle that > case explicitly. Great, thanks!

Re: C API with *args and **kw

2008-10-14 Thread Miki
> > I'm try to write the C equivalent of: > > Use PyArg_ParseTupleAndKeywords() to parse the args and kwargs objects. Couldn't figure out how to get *args with ParseTupleAndKeywords. Thanks, Miki -- http://mail.python.org/mailman/listinfo/python-list

Re: C API with *args and **kw

2008-10-14 Thread Hrvoje Niksic
[ Note that there's a mailing list dedicated to the C API, http://mail.python.org/mailman/listinfo/capi-sig ] Miki <[EMAIL PROTECTED]> writes: > However when running the test: > from kw import kw > kw(default="2") > kw(1) > kw() > > I get "bus error" on the 2'nd call (OS X Python 2.5.2). When

Re: C API with *args and **kw

2008-10-14 Thread Stefan Behnel
Miki wrote: > I'm try to write the C equivalent of: > > def kw(*args, **kw): > print "%d args" % len(args), > if "default" in kw: > print "default is %s" % kw["default"] > else: > print "no default" Consider using Cython instead, it will make your life a lot easier. Th

Re: C API with *args and **kw

2008-10-14 Thread Christian Heimes
Miki wrote: Hello All, I'm try to write the C equivalent of: Use PyArg_ParseTupleAndKeywords() to parse the args and kwargs objects. Christian -- http://mail.python.org/mailman/listinfo/python-list

C API with *args and **kw

2008-10-14 Thread Miki
Hello All, I'm try to write the C equivalent of: def kw(*args, **kw): print "%d args" % len(args), if "default" in kw: print "default is %s" % kw["default"] else: print "no default" I've written: static PyObject * kw(PyObject *self, PyObject *args, PyObject *kwds) {