TypeError: _api() takes 1 positional argument but 2 were given code example
Example 1: TypeError: takes 0 positional arguments but 1 was given python
When Python tells you "generatecode() takes 0 positional arguments but 1 was
given", it's telling you that your method is set up to take no arguments, but
the self argument is still being passed when the method is called, so in fact
it is receiving one argument.
Adding self to your method definition should resolve the problem.
Example 2: 1 positional arguments expected but 2 were given
class thing(object):
def __init__(self):
pass
def function(self)
print("hello")
thingy = thing()
thingy.bind("<KeyPress>", thingy.function)
Example 3: takes 1 positional argument but 2 were given python
This error is often caused by the fact that the self is omitted as a parameter in the method of the class.
https://careerkarma.com/blog/python-takes-one-positional-argument-but-two-were-given/
0