self in extension method
David Morgenthaler
boogiemorg at aol.com
Fri May 3 12:11:42 EDT 2002
My question concerns getting access to self (an instance object) in a
C extension. I'm trying to implement an extension method, but when I
call the method, self always evals to Py_None. Here's the gist of what
I'm trying:
# The Python part
class A:
def __init__(self):
...
def methodofinterest(self,a,b,c):
# Python implementation
try:
from A_ import methodofinterest_
A.methodofinterest = methodofinterest_
except ImportError:
pass
=======================
// The C part
static PyObject* methodofinterest_(PyObject *self, PyObject *args) {
PyObject_Print(self);
//etc.
}
=======================
When, in Python, I invoke a.methodofinterest(1,2,3), the above
PyObject_Print always prints <nil>. How do I get self to give me the
instance a?
Thanks in advance,
More information about the Python-list
mailing list