Error when trying to overload an operator “/”

后端 未结 2 1046
一生所求
一生所求 2020-11-29 08:06

I recently start teaching myself game programming. Someone recommend me to start with Python and I got the book \"Beginning game development with Python and Pygame: From nov

相关标签:
2条回答
  • 2020-11-29 08:30

    In Python 3.x, you need to overload the __floordiv__ and __truediv__ operators, not the __div__ operator. The former corresponds to the // operation (returns an integer) and the latter to / (returns a float).

    0 讨论(0)
  • 2020-11-29 08:53

    In Python 3, the division operators are called __truediv__ and __floordiv__. See the Data model documentation for more information.

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