Re: C API: module cleanup function

2010-01-30 Thread Mr.M
Stefan Behnel ha scritto: Note that there is the type() builtin function which returns the type given an instance. So you can't hide the type. Argh! Yes, you are right. So I'd better have a look to Cython, right? L- -- http://mail.python.org/mailman/listinfo/python-list

Re: C API: module cleanup function

2010-01-30 Thread Mr.M
Stefan Behnel ha scritto: Gabriel already pointed you to the module cleanup support in Py3, which can be used to provide reload capabilities to your module. In Py2, there are at least some ways to free resources when terminating the interpreter. See the "atexit" module and the Py_AtExit() functi

Re: C API: module cleanup function

2010-01-29 Thread Mr.M
Gabriel Genellina ha scritto: I think what you want to do isn't possible with Python 2, and it's one of the reasons the module handling was redesigned in Python 3.x; see PEP 3121. Thank you Gabriel for your help. Unlucky I can't use Python 3.x in my project, sob! Luca. -- http://mail.python

C API: module cleanup function

2010-01-29 Thread Mr.M
Hi, I can't figure out if there is a way to run a specialized cleanup function when a module needs to be "unloaded" (i.e. just before a reload() or when i quit the interpreter). I'm thinking of something like tp_dealloc. If I call Py_InitModule3 and look at module->ob_type->tp_dealloc, I fin

get PyObject* knowing its string name

2010-01-29 Thread Mr.M
I think this sounds like a stupid question, but I searched the C/Api doc and google but I wasn't able to find any hint: how can I retrive PyObject pointer if I only know it's name? What I'd like to do is something like this: [code] PyObject* obj = PyFindWhatImLookingFor("w.z.y.x"); [/code] Of

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 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 Mr.M
Carl Banks ha scritto: (some declarations omitted here) You probably shouldn't have, that could be where the error is I'd include the whole function up to the call that raises the exception. Thank you so much Carl for your help, i'll provide more info so that you can try to fix my errors

PyArg_ParseTupleAndKeywords

2010-01-22 Thread Mr.M
Hi, 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: [code] (some declarations omitted here) static char* keywordlist[] = {"service", "event_type",