How to overload __init__ method based on argument type?
Let’s say I have a class that has a member called data which is a list.
Let’s say I have a class that has a member called data which is a list.
What is the name of the method to override the [] operator (subscript notation) for a class in Python?
If I am creating my own class in Python, what function should I define so as to allow the use of the in operator, e.g.
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 novice to professional”. I got to a part where they teach about Vectors and creating a Vector2 class. Everything was going well until I tried to overload the division operator.
My code goes like this: