[Python-ideas] Improving this? - foo() takes at least 6 arguments (6 given)

Eli Stevens (Gmail) wickedgrey at gmail.com
Sat Sep 3 10:59:57 CEST 2011

On Thu, Sep 1, 2011 at 10:19 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> Colleague:  "So my code is apparently asking for 6 arguments and it
>> appears that I gave it 6 arguments"
>> Me:  "Oh that - Yeah... your short one.  It really wants 7.."
> How did you get this?

Having seen this bite someone recently, I have an example readily at hand:

>>> def f(a,b,c,d=None): pass
>>> f(1,2,d=4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() takes at least 3 arguments (3 given)

The mention of self might be a bit of a red herring, since unless
there's another way to generate the same error message, the error
really is "f() takes at least 3 arguments (2 given, plus 1 keyword
argument not counted here)".


More information about the Python-ideas mailing list