Python Forum
takes 21 positional arguments but 24 were given - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: takes 21 positional arguments but 24 were given (/thread-19270.html)



takes 21 positional arguments but 24 were given - sophsoph - Jun-20-2019

I have a positional argument issue. What needs to be changed?

Error:
"line 277, in <module> ld2 TypeError: mapTraverse() takes 21 positional arguments but 24 were given":
              key, counter, rewardTotal, accuracyHD1, accuracyHD2, newRewardLocation, pointerHD1, pointerHD2, reward1, reward2, ld1, ld2 = sups.mapTraverse(win,
                                                allMapParams[mapDispOrder[mp]][0],
                                                allMapParams[mapDispOrder[mp]][2],
                                                allMapParams[mapDispOrder[mp]][1],
                                                allMapParams[mapDispOrder[mp]][3], 
                                                allMapParams[mapDispOrder[mp]][4],
                                                stateLevels, 
                                                block, 
                                                key, 
                                                counter,
                                                fixationRange,
                                                writer,
                                                maxWaitResponse,
                                                newRewardLocation,
                                                rewardTotal,
                                                [-1], # reward1
                                                -1, # reward2
                                                accuracyHD1,
                                                accuracyHD2,
                                                accuracyCheckFrequency,
                                                pointerHD1,
                                                pointerHD2,
                                                ld1,
                                                ld2
                                                )



RE: takes 21 positional arguments but 24 were given - noisefloor - Jun-20-2019

Hi,

well, the error message is crystal clear: you call a function or method with 24 arguments, but the function / method only accepts / expects 21. So your function call is wrong.

You may want to consult the documentation of the function / method you use to get more details, respectively which arguments are expected.

By the way: 21 positional arguments is super weird, no good design. For this number, the use of keyword arguments is way better. However wrote this function / method...

Regards noisefloor


RE: takes 21 positional arguments but 24 were given - metulburr - Jun-20-2019

Quote:21 positional arguments
Shocked Just pass a dictionary to the function instead.


RE: takes 21 positional arguments but 24 were given - ichabod801 - Jun-20-2019

(Jun-20-2019, 07:20 PM)noisefloor Wrote: By the way: 21 positional arguments is super weird

And 12 return values!


RE: takes 21 positional arguments but 24 were given - DeaD_EyE - Jun-20-2019

You think this is abnormal?
https://bugs.python.org/issue12844
Big Grin Big Grin


RE: takes 21 positional arguments but 24 were given - ichabod801 - Jun-21-2019

Doh