"TypeError: method() takes 1 positional argument but 2 were given" but I only passed one

If I have a class ...

class MyClass:

    def method(arg):
        print(arg)

... which I use to create an object ...

my_object = MyClass()

... on which I call method("foo") like so ...

>>> my_object.method("foo")
Traceback (most recent call last):
  File "", line 1, in 
TypeError: method() takes exactly 1 positional argument (2 given)

... why does Python tell me I gave it two arguments, when I only gave one?

← Назад к списку