Typeerror: __init__() Takes 4 Positional Arguments But 5 Were Given
I have looked up similar questions, yet most problems are related to omitting the self argument in the __init__ definition. Code: class steamurl(): baseurl = 'http://api.steam
Solution 1:
You need to use **
to apply optionsdic
as keyword arguments:
testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", **optionsdic)
otherwise it is just another positional argument passing in a dictionary object.
This mirrors the syntax in the function signature.
Solution 2:
If you want to pass the contents of optionsdic
as separate keyword arguments, you need to use **
unpacking:
testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", **optionsdic)
Solution 3:
You should call using **
:
testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", optionsdic)
This will unpack the dictionary into separate keyword arguments. In __init__
the keyword arguments will then be packed into a dictionary due to **options
.
Post a Comment for "Typeerror: __init__() Takes 4 Positional Arguments But 5 Were Given"