Generic vector aggregates

Fernando Pérez fperez528 at yahoo.com
Mon Jul 8 21:57:41 EDT 2002


Ingo Blank wrote:

> 
> Q:  How can I refer to the built in arithmetic operators "+","*" etc.
> This would save the additional dispatching step, without the need to

look up the special __names like __add__, __mult__, etc.

Here's the output for an integer:

In [19]: x=4

In [20]: x.__
x.__abs__           x.__hash__          x.__or__            x.__ror__
x.__add__           x.__hex__           x.__pos__           x.__rpow__
x.__and__           x.__init__          x.__pow__           x.__rrshift__
x.__class__         x.__int__           x.__radd__          x.__rshift__
x.__cmp__           x.__invert__        x.__rand__          x.__rsub__
x.__coerce__        x.__long__          x.__rdiv__          x.__rtruediv__
x.__delattr__       x.__lshift__        x.__rdivmod__       x.__rxor__
x.__div__           x.__mod__           x.__reduce__        x.__setattr__
x.__divmod__        x.__mul__           x.__repr__          x.__str__
x.__doc__           x.__neg__           x.__rfloordiv__     x.__sub__
x.__float__         x.__new__           x.__rlshift__       x.__truediv__
x.__floordiv__      x.__nonzero__       x.__rmod__          x.__xor__
x.__getattribute__  x.__oct__           x.__rmul__

Many of those special methods are what really gets called when binary 
operators are applied to integers. The docs have more details.


cheers,

f.



More information about the Python-list mailing list