[Zope-dev] ExtensionClass and __radd__()?

Pavlos Christoforou pavlos@gaaros.com
Thu, 6 Jul 2000 08:46:50 -0400 (EDT)


On Wed, 5 Jul 2000, Greg Ward wrote:

> 
> Well, it's a nice theory.  It doesn't explain why '__add__()' works for
> ExtensionClass while '__radd__()' does not; perhaps ExtensionClass
> implements that much of Python's class semantics, but doesn't go as far
> as '__radd__()'.
> 

A quick note which you probably already know:

grep add ExtensionClass.c gives:

static PyObject *py__add__, *py__sub__, *py__mul__, *py__div__,
  INIT_PY_NAME(__add__); BINOP(add,Add)
      FILLENTRY(nm->nb, add, add, METH_VARARGS, "Add to another");
      FILLENTRY(sm->sq, concat, add, METH_VARARGS,
          SET_SPECIAL(add,add); subclass_add(PyObject *self, PyObject *v)
  UNLESS(m=subclass_getspecial(self,py__add__)) return NULL;
          && AsCMethod(m)->meth==(PyCFunction)add_by_name
    ASSIGN(m,AsCMethod(m)->type->tp_as_number->nb_add(self,v));
  (binaryfunc)subclass_add, /*nb_add*/
        (binaryfunc)subclass_add, /*sq_concat*/
      return; /* we added a reference; don't delete now */ 

whereas grep radd ExtensionClass.c returns nothing


Pavlos