Operator overloading in Python: handling different types and order of parameters [duplicate]
- 阅读更多 关于 Operator overloading in Python: handling different types and order of parameters [duplicate]
问题 This question already has an answer here : Python commutative operator override (1 answer) Closed 2 years ago . I have a simple class that helps with mathematical operations on vectors (i.e. lists of numbers). My Vector can be multiplied by other instances of Vector or a scalar ( float or int ). In other, more strongly typed, languages I would create a method to multiply two vector s and a separate method to multiply a vector by and int / float . I'm still pretty new to Python and am not sure