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
  • 163
  • 2
  • 5
  • 14

3 Answers3

2

You'll want the double star:

def GroupGeneralConfig(self, **kwargs):
    img = str(kwargs[selectedStreamGroup]) + "abc"
Community
  • 1
  • 1
miku
  • 172,072
  • 46
  • 300
  • 307
1

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

def GroupGeneralConfig(self, **kwargs):
filmor
  • 28,551
  • 4
  • 47
  • 46
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
  • 31,549
  • 25
  • 88
  • 134