0

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

Yashwanth Nataraj
  • 183
  • 3
  • 5
  • 16

3 Answers3

2

You'll want the double star:

def GroupGeneralConfig(self, **kwargs):
    img = str(kwargs[selectedStreamGroup]) + "abc"
Community
  • 1
  • 1
miku
  • 181,842
  • 47
  • 306
  • 310
1

If you want to use kwargs you should define it first:

def GroupGeneralConfig(self, **kwargs):
filmor
  • 30,840
  • 6
  • 50
  • 48
1

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)
Amyth
  • 32,527
  • 26
  • 93
  • 135