Python Forum

Full Version: takes 21 positional arguments but 24 were given
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
                                                )
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
Quote:21 positional arguments
Shocked Just pass a dictionary to the function instead.
(Jun-20-2019, 07:20 PM)noisefloor Wrote: [ -> ]By the way: 21 positional arguments is super weird

And 12 return values!
You think this is abnormal?
https://bugs.python.org/issue12844
Big Grin Big Grin
Doh