Python method takes one positional argument but two were given

Viewed 3828

I came across an error which I don't quite understand. If I have the following snippet:

class Test(object):
  def __init__(self):
    self.data = {}

  def update_data(self, **update):
    self.data = update

t = Test()

t.update_data(test='data') #  Works
t.update_data({'test':'data'}) #  TypeError: update_data() takes 1 positional argument but 2 were given

So from what I understand, the **update syntax is the dictionary destructing syntax and when you pass a dict to the function, it gets converted into keyword arguments.

What am I understanding improperly here?

2 Answers
Related