#1269 floating point division operator not generated

open
nobody
python (259)
5
2013-03-27
2012-09-03
Michel Zou
No

Hi,

python 3 requires the floating point division operator to be __truediv__,
for the moment (2.0.8) it is not generated:

%module example

class Foo
{
public:
Foo();
Foo(double x);
Foo operator/(double x);
};

generates only:
def __div__(self, *args): return _example.Foo___div__(self, *args)

so we get the following exception when trying to do divide an instance of (Foo=a(3); print a/3")
TypeError: unsupported operand type(s) for /: 'Foo' and 'float'

it seems to be the same for the in-place division operator __itruediv__

regards,
x.

Discussion

  • Dixit Patel
    Dixit Patel
    2013-03-27

    Hello
    I am new to swig and would like to solve this issue if its still valid. Can you direct me on how to go about on this?