Re: PROPOSAL: A Generic Python Object Interface for Python C Modules

Donald Beaudry (don@dvcorp.com)
Thu, 02 Mar 1995 16:24:17 -0500

> > Should "__add__" etc. work for built-in object types (e.g. integers)
> > too? That would be nice but lots of work, since it isn't implemented
> > currently.
>
> It woudn't be that much work. I'd first try to get the attribute. If
> that failed, I'd check a dictionary of special attributes. If the
> attribute that is not found is special, then I'd try to call the
> special function. This can be done without much code.
>

Not really, with build-in objects there is no entry anywhere for
__add__ or any other special symbols. In the current implementation
of classes, for example, if you override the __repr__ method, you can
no longer get at the default version. That is

class pig_innards:
pass

class spam(pig_innards):
def __repr__(self):
if self.eggs:
return self.ham
else:
return pig_innards.__repr__(self)

So, even though class pig_innards does not implement a __repr__
method, you can still 'repr' one of its instances. But, you can't ask
it for its '__repr__' attribute. The changes necessary to correct
this are not trivial. I happen to think that it should work, and
belive it or not, in my implementation of classes actually does.

B.T.W, I really like the proposal that started this thread.

--
Donald Beaudry                                DataViews Corporation
Software Engineer                             47 Pleasant Street
don@dvcorp.com                                Northampton, MA 01060
		  "So much code, so little time..."