- In the Python example below, notice how the method setSides has two formal parameters, but when we call it in main(), we only pass one argument.
def setSides(self, sides):
self.numSides = sides
die1 = Die()
- If students are learning Object-Oriented Programming while transitioning between two languages, like Python and Java, this can be even more confusing.
- In Java,
selfis an implicit argument when a method is defined. In Python,
selfis an explicit argument. In both Python and Java,
selfisn’t a required argument when the method/function is called.
- As such, students struggle with reasoning about object oriented function declarations between Python and Java.
- If students are moving from Python to Java, point them to Ken Lambert’s Python to Java resource for additional help.