[Python-ideas] Improving this? - foo() takes at least 6 arguments (6 given)
benjamin at python.org
Sat Sep 3 16:16:16 CEST 2011
Eli Stevens (Gmail <wickedgrey at ...> writes:
> On Thu, Sep 1, 2011 at 10:19 AM, Ethan Furman <ethan at ...> 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)".
Coming your way soon:
Python 3.3.0a0 (default:fe0497bd7354, Sep 3 2011, 10:14:20)
[GCC 4.4.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(a,b,c,d=None): pass
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() missing 1 required positional argument: 'c'
More information about the Python-ideas