[Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
I suspect I've missed the boat on this one (certainly for 3.3.0), but here goes. The new TypeError reporting for bad function calls is a huge improvement (thanks Benjamin!), but I have one small nitpick: what *is* a positional argument? For example: def f(x): pass ... f()

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Nick Coghlan
On Thu, Sep 20, 2012 at 9:56 PM, Mark Dickinson dicki...@gmail.com wrote: I submit that the word 'positional' in the TypeError message exacerbates this confusion, and that little would be lost by simply dropping it from the exception message. +1 for using the unqualified argument in these

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
On Thu, Sep 20, 2012 at 1:21 PM, Nick Coghlan ncogh...@gmail.com wrote: +1 for using the unqualified argument in these error messages to mean positional or keyword argument (inspect.Parameter spells it out as POSITIONAL_OR_KEYWORD, but the full phrase is far too verbose for an error message).

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Nick Coghlan
On Thu, Sep 20, 2012 at 10:59 PM, Mark Dickinson dicki...@gmail.com wrote: Perhaps this simply isn't worth worrying about, especially since the current error messages are all but certain to make it into the 3.3 release. No all but about it at this point - the earliest they could change again

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Benjamin Peterson
2012/9/20 Mark Dickinson dicki...@gmail.com: Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only, positional. For example, in def f(a, b, c, *args, d): pass a, b, and c are

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Chris Jerdonek
On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson benja...@python.org wrote: def f(a, b, c, *args, d): pass a, b, and c are positional. Hence the positional in error messages. As you noted in your next message, keyword-only arguments need to be distinguished from these positional

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Antoine Pitrou
On Thu, 20 Sep 2012 10:12:04 -0400 Benjamin Peterson benja...@python.org wrote: 2012/9/20 Mark Dickinson dicki...@gmail.com: Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only,

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
On Thu, Sep 20, 2012 at 3:12 PM, Benjamin Peterson benja...@python.org wrote: As you noted in your next message, keyword-only arguments need to be distinguished from these positional arguments somehow. Maybe it helps to think of positional to mean the only formals you can pass to with

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Benjamin Peterson
2012/9/20 Mark Dickinson dicki...@gmail.com: And excepting optional ones, too, right? E.g., the c in def foo(a, b, c=1, *args, d): pass can be passed to by position, but isn't positional. Why not? def f(a, b, c=3): pass ... f() Traceback (most recent call last): File

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Mark Dickinson
On Thu, Sep 20, 2012 at 4:14 PM, Benjamin Peterson benja...@python.org wrote: 2012/9/20 Mark Dickinson dicki...@gmail.com: And excepting optional ones, too, right? E.g., the c in def foo(a, b, c=1, *args, d): pass can be passed to by position, but isn't positional. Why not?

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Guido van Rossum
On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson benja...@python.org wrote: 2012/9/20 Mark Dickinson dicki...@gmail.com: Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only,

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Oscar Benjamin
On 20 September 2012 16:14, Benjamin Peterson benja...@python.org wrote: 2012/9/20 Mark Dickinson dicki...@gmail.com: And excepting optional ones, too, right? E.g., the c in def foo(a, b, c=1, *args, d): pass can be passed to by position, but isn't positional. Why not?

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Terry Reedy
On 9/20/2012 7:56 AM, Mark Dickinson wrote: I suspect I've missed the boat on this one (certainly for 3.3.0), but here goes. The new TypeError reporting for bad function calls is a huge improvement (thanks Benjamin!), but I have one small nitpick: what *is* a positional argument? For example:

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Terry Reedy
On 9/20/2012 10:12 AM, Benjamin Peterson wrote: 2012/9/20 Mark Dickinson dicki...@gmail.com: Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or keyword-only, positional. For example, in def f(a, b,

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Chris Jerdonek
On Thu, Sep 20, 2012 at 8:52 AM, Guido van Rossum gu...@python.org wrote: On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson benja...@python.org wrote: I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic, keyword variadic, or

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Terry Reedy
On 9/20/2012 11:52 AM, Guido van Rossum wrote: Maybe this is also a good time to start distinguishing between arguments (what you pass, call syntax) and parameters (what the function receives, function definition syntax)? One standard usage (and mine) is that parameters are the (local) names

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 20/09/12 22:59, Mark Dickinson wrote: On Thu, Sep 20, 2012 at 1:21 PM, Nick Coghlanncogh...@gmail.com wrote: +1 for using the unqualified argument in these error messages to mean positional or keyword argument (inspect.Parameter spells it out as POSITIONAL_OR_KEYWORD, but the full phrase is

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 00:49, Antoine Pitrou wrote: On Thu, 20 Sep 2012 10:12:04 -0400 Benjamin Petersonbenja...@python.org wrote: 2012/9/20 Mark Dickinsondicki...@gmail.com: Thoughts? I tried to define the error messages in terms of the callee's signature. I call the formals that are not variadic,

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 01:53, Oscar Benjamin wrote: Mark Dickinson wrote: def f(x): pass ... f() Traceback (most recent call last): File stdin, line 1, inmodule TypeError: f() missing 1 required positional argument: 'x' I would say that the only problem with this terminology is that it would be

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Chris Jerdonek
On Thu, Sep 20, 2012 at 10:18 AM, Chris Jerdonek chris.jerdo...@gmail.com wrote: On Thu, Sep 20, 2012 at 8:52 AM, Guido van Rossum gu...@python.org wrote: On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson benja...@python.org wrote: I tried to define the error messages in terms of the

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Ethan Furman
Steven D'Aprano wrote: On 20/09/12 22:59, Mark Dickinson wrote: On Thu, Sep 20, 2012 at 1:21 PM, Nick Coghlanncogh...@gmail.com wrote: +1 for using the unqualified argument in these error messages to mean positional or keyword argument (inspect.Parameter spells it out as

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Ethan Furman
Steven D'Aprano wrote: I would like to see error messages reserve the terms: 1) positional for explicitly positional-only parameters; 2) keyword for explicitly keyword-only parameters; +1 ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Steven D'Aprano
On 21/09/12 05:45, Ethan Furman wrote: I don't expect error messages to give a complete catalog of every problem with a specific function call. If f() reports that required argument 'a' is missing, that does not imply that no other required arguments are also missing. I think it is perfectly

Re: [Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

2012-09-20 Thread Nick Coghlan
We've already had this terminology discussion and documented the results in PEP 362. The rest of the docs may require updates to be brought in line with that. Cheers, Nick. -- Sent from my phone, thus the relative brevity :) ___ Python-Dev mailing list