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

Mark Dickinson dickinsm at gmail.com
Sat Sep 3 13:02:34 CEST 2011


On Sat, Sep 3, 2011 at 9:59 AM, Eli Stevens (Gmail)
<wickedgrey at gmail.com> wrote:
> 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)

Isn't this already fixed for Python 3.3?

Python 3.3.0a0 (default:a8748022504f, Sep  2 2011, 12:32:36)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(a, b, c, d=None): pass
...
[63593 refs]
>>> f(1, 2, d=4)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
TypeError: f() missing 1 required positional argument: 'c'
[63624 refs]



More information about the Python-ideas mailing list