Improving this? - foo() takes at least 6 arguments (6 given)
On Sat, Sep 3, 2011 at 9:59 AM, Eli Stevens (Gmail)
On Thu, Sep 1, 2011 at 10:19 AM, Ethan Furman
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]
2011/9/3 Mark Dickinson
On Sat, Sep 3, 2011 at 9:59 AM, Eli Stevens (Gmail)
wrote: On Thu, Sep 1, 2011 at 10:19 AM, Ethan Furman
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]
Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas
This is a very good improvement I wasn't aware of! Glad to see that. Regards, --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/
On Mon, Sep 5, 2011 at 7:36 PM, Giampaolo Rodolà
This is a very good improvement I wasn't aware of! Glad to see that.
You can see some more examples of the results of Benjamin's work on this problem in the updated test suite: http://hg.python.org/cpython/file/31b3218794e2/Lib/test/test_extcall.py#l298 Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (3)
-
Giampaolo Rodolà
-
Mark Dickinson
-
Nick Coghlan