Reputation: 193
I am trying to pass argument to a function in this fashion
GroupGeneralConfig(selectedGroup = "Group1")
and the function looks like this...
def GroupGeneralConfig(self, *args)
img = str(args[0]) + "abc"
whenever i execute this program it is throwing like this...
TypeError: GroupGeneralConfig() got an unexpected keyword argument 'selectedGroup'
whats wrong here
Upvotes: 0
Views: 101
Reputation: 32949
What you are passing in is a keyword argument, change your method to accept keyword arguments first. Like this
def GroupGeneralConfig(self, *args, **kwargs)
img = str(args[0]) + "abc"
Then you can pass the arguments first and then the keyword arguments, like:
GroupGeneralConfig(arg_x, arg_y, kwarg_x=1, kwarg_y=2)
Upvotes: 1
Reputation: 188004
You'll want the double star:
def GroupGeneralConfig(self, **kwargs):
img = str(kwargs[selectedStreamGroup]) + "abc"
Upvotes: 2
Reputation: 32182
If you want to use kwargs
you should define it first:
def GroupGeneralConfig(self, **kwargs):
Upvotes: 1