Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Python 2.5: wrong number of arguments given in TypeError forfunction argument aggregation (dictionary input vs the norm)

Reply
Thread Tools

Re: Python 2.5: wrong number of arguments given in TypeError forfunction argument aggregation (dictionary input vs the norm)

 
 
M.-A. Lemburg
Guest
Posts: n/a
 
      10-31-2008
On 2008-10-31 00:18, John Krukoff wrote:
> On Fri, 2008-10-31 at 08:55 +1000, James Mills wrote:
>> What you have discovered is not a bug
>>
>> cheers
>> James
>>

>
> Are you sure? It looks like his complaint isn't that it doesn't work,
> but that the error message is misleading.
>
> With the setup:
>
> Python 2.5.2 (r252:60911, Sep 22 2008, 12:08:3
> [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> def foo( a, b, c ):

> ... pass
> ...
>
> Compare the error messages from:
>
>>>> foo( **{ 'a' : 1, 'c' : 3 } )

> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: foo() takes exactly 3 non-keyword arguments (1 given)
>
> to the error message here:
>
>>>> foo( **{ 'a' : 1, 'b' : 3 } )

> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: foo() takes exactly 3 non-keyword arguments (2 given)


The (n given) notice refers to the number of keyword parameters
you specified in the call that could be associated with a
non-keyword arguments of the function.

I agree that this is a bit misleading.

Please open a bug report on python.org.

> Is it even possible to get an error message in terms of required keyword
> arguments? I seem to remember seeing a note about keyword only arguments
> recently...


You probably saw PEP 3102:

http://www.python.org/dev/peps/pep-3102/

That has a somewhat different focus though: it allows defining
keyword-only arguments, ie. ones that cannot be used as
both non-keyword parameter and keyword parameter (like we
have in Python 2.x).

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source (#1, Oct 31 200
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/

__________________________________________________ ______________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TypeError: __init__() takes exactly 1 positional argument (2 given) Gnarlodious Python 9 05-16-2011 05:08 AM
Re: TypeError: _new_() takes exactly 3 arguments (2 given) - whatdoes it mean? Terry Reedy Python 1 05-26-2010 07:04 PM
Solved: TypeError: startView() takes exactly 1 argument (3 given) Ron Croonenberg Python 0 12-30-2009 05:01 PM
Re: TypeError: startView() takes exactly 1 argument (3 given) Ron Croonenberg Python 0 12-30-2009 03:43 PM
TypeError: startView() takes exactly 1 argument (3 given) Ron Croonenberg Python 0 12-30-2009 02:00 AM



Advertisments