Python Class __div__ issue

后端 未结 2 765
走了就别回头了
走了就别回头了 2020-12-03 21:06

The tuples represent fractions. I\'m trying to divide the fractions by multiplying by the reciprical

class Test():
    def __init__(self):
        self._x=(1         


        
2条回答
  •  死守一世寂寞
    2020-12-03 21:16

    had the same problem the other day.

    see if __future__.division is active in your environment. if so, you need to define __truediv__ as well.

    http://docs.python.org/2/library/operator.html#mapping-operators-to-functions

提交回复
热议问题