Aug-19-2019, 09:29 AM
Hi, i have an example project where i try to pass a dictionary as "**kwargs" to a method. Unfortunately this does not work and i dont know why.
Here is my example-Code:
Traceback (most recent call last):
File "main.py", line 17, in <module>
myMethod(_MyDict)
TypeError: myMethod() takes 0 positional arguments but 1 was given
...Program finished with exit code 1
Press ENTER to exit console.
Thanks for Help
Here is my example-Code:
_MyDict = {"age":"25", "name":"Frank"} def myMethod(**kwargs): Name = kwargs.pop('Name', 'InitialName') Age = kwargs.pop('Age', 'InitialAge') print("Name:" + Name) print("Age:" + Age) myMethod(_MyDict)By executing this script, i get the following error:
Traceback (most recent call last):
File "main.py", line 17, in <module>
myMethod(_MyDict)
TypeError: myMethod() takes 0 positional arguments but 1 was given
...Program finished with exit code 1
Press ENTER to exit console.
Thanks for Help