I am writing a binding system that provides classes and functions for python in a somewhat unusual way.
You can usually create a python type and provide a list of functions representing methods of this type, and then let python use its generic tp_getattro function to choose the right one.
For reasons that I will not enter here, I cannot do this and must provide my own function tp_getattro, which selects methods from another place and returns my own shell 'bound method'. This works great, but means that type methods are not listed in his dictionary (therefore, it dir(MyType())doesn't show anything interesting).
The problem is that I cannot get the methods to work __add__. see the following example:
>>> from mymod import Vec3
>>> v=Vec3()
>>> v.__add__
<Bound Method of a mymod Class object at 0xb754e080>
>>> v.__add__(v)
<mymod.Vec3 object at 0xb751d710>
>>> v+v
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'mymod.Vec3' and 'mymod.Vec3'
, Vec3 __add__, , python + .
python ? + python , , ?
.
(P.S. , Boost.Python SWIG, , , .)