Skip to content Skip to sidebar Skip to footer

Python Call Method On Integer Object

I just want to understand the behavior of method call on integer object. I can't call __add__ method directly on integer. 5.__add__(5) This gives me: SyntaxError: invalid syntax H

Solution 1:

it is just syntax. The Parser reads:

  • "5." -> a float :)
  • "__add__" -> why that? I don't understand :(

Post a Comment for "Python Call Method On Integer Object"