Python Class __div__ issue

后端 未结 2 752
走了就别回头了
走了就别回头了 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:10

    Python 3.x uses __truediv__ and __floordiv__. __div__ is 2.x-only.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题