[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Rob Cliffe via Python-ideas
On 06/12/2021 23:13, Steven D'Aprano wrote: On Mon, Dec 06, 2021 at 10:17:06AM +, Rob Cliffe via Python-ideas wrote: If your language only has one, early binding is better. That's your opinion.  It's not mine.  Witness the Stack Overflow questions asking why `def f(arg=[])` "doesn't work

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Neil Girdhar
On Monday, December 6, 2021 at 6:28:10 PM UTC-5 Steven D'Aprano wrote: > On Mon, Dec 06, 2021 at 11:57:11AM -0800, Neil Girdhar wrote: > > > Has anyone done a survey of, say, the cpython library codebase to see > what > > proportion of arguments lists would significantly benefit from this PEP

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Steven D'Aprano
On Mon, Dec 06, 2021 at 09:25:23PM +, Barry Scott wrote: > You can shoot your self in the foot with early-binding with ease. > You have to try harder with late-binding :-) def func(arg, sessionid=>secrets.token_hex()): ... "Why does the default session ID change every time I call

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Steven D'Aprano
On Mon, Dec 06, 2021 at 11:57:11AM -0800, Neil Girdhar wrote: > Has anyone done a survey of, say, the cpython library codebase to see what > proportion of arguments lists would significantly benefit from this PEP > given as a proportion of the total codebase? In all the Python I've ever > writ

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Steven D'Aprano
On Mon, Dec 06, 2021 at 10:17:06AM +, Rob Cliffe via Python-ideas wrote: > >If your language only has one, early binding is better. > > That's your opinion.  It's not mine.  Witness the Stack Overflow > questions asking why `def f(arg=[])` "doesn't work". Of course it works. It does *exactly

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Steven D'Aprano
On Mon, Dec 06, 2021 at 10:33:43AM +0100, Piotr Duda wrote: > You can simply write > def func(arg=>FUNC_DEFAULT_VALUE): Doh! Of course you can! I knew that! :-( -- Steve ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an e

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Barry Scott
> On 6 Dec 2021, at 00:31, Finn Mason wrote: > > On Sun, Dec 5, 2021, 12:11 PM Brendan Barnwell > wrote: > On 2021-12-04 20:01, David Mertz, Ph.D. wrote: > > > > There are perfectly good ways to "fake" either one if you only have the > > other. Probably more work

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Neil Girdhar
Has anyone done a survey of, say, the cpython library codebase to see what proportion of arguments lists would significantly benefit from this PEP given as a proportion of the total codebase? In all the Python I've ever written or seen, I can only thing of one example of a custom sentinel ever

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Rob Cliffe via Python-ideas
On 06/12/2021 08:45, Steven D'Aprano wrote: On Sun, Dec 05, 2021 at 05:31:58PM -0700, Finn Mason wrote: Also, on a kind of side note, what would be a situation where early binding is advantageous to late binding? I can't think of one off the top of my head. If your language only has one, ear

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Stephen J. Turnbull
Finn Mason writes: > Is its not being done before really a good argument against it? No, but that's not the whole of the argument being made. The implied argument is that having two different ways to evaluate defaults is complexity that arguably isn't needed: either because late binding is a YA

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-06 Thread Steven D'Aprano
On Sun, Dec 05, 2021 at 05:31:58PM -0700, Finn Mason wrote: > Also, on a kind of side note, what would be a situation where early binding > is advantageous to late binding? I can't think of one off the top of my > head. If your language only has one, early binding is better. You can easily simul

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-05 Thread David Mertz, Ph.D.
On Sun, Dec 5, 2021 at 6:44 PM Steven D'Aprano wrote: > How do you get nine in the first place? Putting aside *args and > **kwargs, the existing parameter matrix is either 3x2 or 3x2x∞ depending > on whether you include types as part of the matrix. > which makes 3x2 = 6, not 9. Adding a distincti

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-05 Thread Finn Mason
On Sun, Dec 5, 2021, 12:11 PM Brendan Barnwell wrote: > On 2021-12-04 20:01, David Mertz, Ph.D. wrote: > > > > There are perfectly good ways to "fake" either one if you only have the > > other. Probably more work is needed to simulate early binding, but there > > are ways to achieve the same effe

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-05 Thread Steven D'Aprano
On Sat, Dec 04, 2021 at 11:39:00PM -0500, David Mertz, Ph.D. wrote: > Wow! That's an even bigger teaching nightmare than I envisioned in my > prior post. Nine (3x3) different kinds of parameters is already too big of > a cognitive burden. Doubling that to 18 kinds makes me shudder. I admit I >

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-05 Thread Brendan Barnwell
On 2021-12-04 20:01, David Mertz, Ph.D. wrote: There are perfectly good ways to "fake" either one if you only have the other. Probably more work is needed to simulate early binding, but there are ways to achieve the same effect. However, that language would not be Python. That ship sailed in 19

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-05 Thread Rob Cliffe via Python-ideas
On 05/12/2021 04:01, David Mertz, Ph.D. wrote: The cost here is that EVERY SINGLE student learning Python needs to add this new construct to their mental load. EVERY book and tutorial needs to be updated. EVERY experienced developer has to spend extra effort understanding and writing code.

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 3:39 PM David Mertz, Ph.D. wrote: > > On Sat, Dec 4, 2021 at 11:25 PM Chris Angelico wrote: >> >> > def add(a, b): >> > return a+b >> > How could you write that differently with your PEP >> >> I wouldn't. There are no default arguments, and nothing needs to be changed.

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread David Mertz, Ph.D.
On Sat, Dec 4, 2021 at 11:25 PM Chris Angelico wrote: > > def add(a, b): > > return a+b > > How could you write that differently with your PEP > > I wouldn't. There are no default arguments, and nothing needs to be > changed. > I do recognize that I *could* call that with named arguments. I

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 3:17 PM David Mertz, Ph.D. wrote: > > On Sat, Dec 4, 2021, 11:13 PM Chris Angelico >> >> Not sure I'm understanding you correctly; in what way are named parameters >> relevant here? > > > def add(a, b): > return a+b > > How could you write that differently with your PEP

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread David Mertz, Ph.D.
On Sat, Dec 4, 2021, 11:13 PM Chris Angelico > Not sure I'm understanding you correctly; in what way are named parameters > relevant here? > def add(a, b): return a+b How could you write that differently with your PEP (which only pertains to named parameters, not positional)? >

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 3:03 PM David Mertz, Ph.D. wrote: > Probably fewer than half of functions I've written use named parameters at > all. > Not sure I'm understanding you correctly; in what way are named parameters relevant here? ChrisA ___ Python-

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread David Mertz, Ph.D.
On Sat, Dec 4, 2021, 10:14 PM Rob Cliffe via Python-ideas > The designers of 12 languages have chosen to provide late binding; those > of 3 or 4 have provided early binding. > I think this is at least tenuous evidence in favour of my belief that late > binding is more useful than early binding. >

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 2:14 PM Rob Cliffe via Python-ideas wrote: > > Thank you for doing this research, Steven. > The designers of 12 languages have chosen to provide late binding; those > of 3 or 4 have provided early binding. > I think this is at least tenuous evidence in favour of my belief th

[Python-ideas] Re: PEP 671 review of default arguments evaluation in other languages

2021-12-04 Thread Rob Cliffe via Python-ideas
Thank you for doing this research, Steven. The designers of 12 languages have chosen to provide late binding; those of 3 or 4 have provided early binding. I think this is at least tenuous evidence in favour of my belief that late binding is more useful than early binding. Best wishes Rob Cliffe