[Python-Dev] Re: Proposal: Allow non-default after default arguments

2023-10-16 Thread Samuel T.
+1 on this. Typeshed is full of examples of extra overloads due to this. Mainly because of a case where a parameter with a default argument isn't actually optional (ie, using the default argument would necessary lead to an error). openpyxl stubs in particular is chockful of them. ___

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Richard Damon
On 11/9/21 3:24 PM, Terry Reedy wrote: On 11/9/2021 1:52 PM, Sebastian Rittau wrote: Am 09.11.21 um 19:26 schrieb Terry Reedy: The signature of Sebastian's function with honest parameter names is foo(x_or_y, required_y=_NotGiven, /).  It is the 2nd argument, not the first, that is optional, as

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Guido van Rossum
On Tue, Nov 9, 2021 at 12:27 PM Terry Reedy wrote: > On 11/9/2021 1:52 PM, Sebastian Rittau wrote: > > Am 09.11.21 um 19:26 schrieb Terry Reedy: > >> The signature of Sebastian's function with honest parameter names is > >> foo(x_or_y, required_y=_NotGiven, /). It is the 2nd argument, not the >

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Terry Reedy
On 11/9/2021 1:52 PM, Sebastian Rittau wrote: Am 09.11.21 um 19:26 schrieb Terry Reedy: The signature of Sebastian's function with honest parameter names is foo(x_or_y, required_y=_NotGiven, /).  It is the 2nd argument, not the first, that is optional, as with range.  If required_y is not given

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Sebastian Rittau
Am 09.11.21 um 19:26 schrieb Terry Reedy: The signature of Sebastian's function with honest parameter names is foo(x_or_y, required_y=_NotGiven, /).  It is the 2nd argument, not the first, that is optional, as with range.  If required_y is not given, than x_or_y must be y, and x is given a defa

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Terry Reedy
On 11/9/2021 9:23 AM, Steven D'Aprano wrote: By the way, this discussion is probably better suited to the Python-Ideas mailing list. But since we're here... On Tue, Nov 09, 2021 at 11:37:40AM +0100, Sebastian Rittau wrote: To me, the "natural" solution looks like this: def foo(x=None, y): ...

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Brett Cannon
On Tue, Nov 9, 2021 at 6:31 AM Steven D'Aprano wrote: > By the way, this discussion is probably better suited to the > Python-Ideas mailing list. But since we're here... > > On Tue, Nov 09, 2021 at 11:37:40AM +0100, Sebastian Rittau wrote: > > > >>To me, the "natural" solution looks like this: >

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Sebastian Rittau
Am 09.11.21 um 13:44 schrieb Petr Viktorin: And for the "encoding" case: IMO, varying the return type based on an optional "encoding" argument" is a holdover from the pre-typing era, when return types were only specified in the documentation -- just like "addch" is a holdover from the days when

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Steven D'Aprano
By the way, this discussion is probably better suited to the Python-Ideas mailing list. But since we're here... On Tue, Nov 09, 2021 at 11:37:40AM +0100, Sebastian Rittau wrote: > >>To me, the "natural" solution looks like this: > >> > >>def foo(x=None, y): ... [...] Chris Angelico asked: > >Wh

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Victor Stinner
IMO it was a bad idea to merge 2 ncurses C functions into a single Python function. In the C API, there are two different functions: * mvwadd_wch(win, y, x, char): 4 arguments * wadd_wch(win, char): 2 arguments The Python curses module could/can have a separated function when (y, x) arguments are

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Petr Viktorin
On 09. 11. 21 10:50, Chris Angelico wrote: On Tue, Nov 9, 2021 at 8:38 PM Sebastian Rittau wrote: Currently, Python doesn't allow non-default arguments after default arguments: >>> def foo(x=None, y): pass File "", line 1 def foo(x=None, y): pass ^ Syntax

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Paul Moore
On Tue, 9 Nov 2021 at 10:39, Sebastian Rittau wrote: > This might be better API design (although I don't think Python should be > opinionated about this outside the standard library), but this still > leaves the API change example and the very real problem of @overloads > unsolved. You can handl

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Sebastian Rittau
Am 09.11.21 um 10:50 schrieb Chris Angelico: On Tue, Nov 9, 2021 at 8:38 PM Sebastian Rittau wrote: Currently, Python doesn't allow non-default arguments after default arguments: >>> def foo(x=None, y): pass File "", line 1 def foo(x=None, y): pass ^ SyntaxEr

[Python-Dev] Re: Proposal: Allow non-default after default arguments

2021-11-09 Thread Chris Angelico
On Tue, Nov 9, 2021 at 8:38 PM Sebastian Rittau wrote: > > Currently, Python doesn't allow non-default arguments after default > arguments: > > >>> def foo(x=None, y): pass >File "", line 1 > def foo(x=None, y): pass > ^ > SyntaxError: non-default argument follows d