[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults -- choice of -> vs @

2021-11-03 Thread Chris Angelico
On Thu, Nov 4, 2021 at 4:56 AM Steven D'Aprano wrote: > > On Thu, Nov 04, 2021 at 04:36:27AM +1100, Chris Angelico wrote: > > > You use the name because you can't refer to it other than by name, and > > that's fine. But it's the *default* that is differ

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-03 Thread Chris Angelico
On Thu, Nov 4, 2021 at 5:28 AM Stephen J. Turnbull wrote: > > > And that's what happens when you need to be pedantically correct. Not > > particularly useful to a novice, especially with the FUD at the > > end. > > I have no idea what you mean by "that's what happens," except that > apparently

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-03 Thread Chris Angelico
On Thu, Nov 4, 2021 at 5:54 AM Ethan Furman wrote: > > On 11/3/21 12:13 AM, Chris Angelico wrote: > > > Python has a strong policy of evaluating things immediately, or being > > very clear about when they will be evaluated > > Putting the marker in the middle of the

[Python-ideas] Re: Beginners accidentally shadow module names due to different expectation of the resolution order for module imports

2021-11-03 Thread Chris Angelico
On Thu, Nov 4, 2021 at 6:37 AM Ethan Furman wrote: > > On 11/3/21 12:21 PM, Florian Wetschoreck wrote: > > > In order to prevent confusion, I want to point out that the primary > scenario that I meant is not that the file imports > > itself but another file in the same directory with the name o

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-03 Thread Chris Angelico
On Thu, Nov 4, 2021 at 9:33 AM Ethan Furman wrote: > > On 11/3/21 2:31 PM, Chris Angelico wrote: > > On Thu, Nov 4, 2021 at 5:54 AM Ethan Furman wrote: > >> On 11/3/21 12:13 AM, Chris Angelico wrote: > > >>> Python has a strong policy of evaluating thin

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-03 Thread Chris Angelico
On Thu, Nov 4, 2021 at 12:42 PM David Mertz, Ph.D. wrote: > This seems exactly opposite the real situation. Late binding is completely > and straightforwardly handled by a sentinel. Yes, it doesn't make the > automatic help() that pretty. Yes it takes an extra line in the body. But the > semant

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-03 Thread Chris Angelico
On Thu, Nov 4, 2021 at 3:56 PM Christopher Barker wrote: > All that being said, like any other PEP, there are two questions: > > 1) will this be an improvement? > 2) if so, is it worth the churn? > > And the SC will need to make those decisions. > > FWIW, I’m not totally sure where I come down on

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-04 Thread Chris Angelico
On Fri, Nov 5, 2021 at 7:36 AM Rob Cliffe via Python-ideas wrote: > But consider this: AFAICS, *everything* you can do with early binding, you > can do with late binding, but *not* vice versa. (To simulate early binding > if you actually only have late binding, simply put the default value in a

[Python-ideas] Re: Call two or more functions with one args

2021-11-05 Thread Chris Angelico
On Sat, Nov 6, 2021 at 1:06 AM one last Day wrote: > > > Call two or more functions with one args. > one last Day > إلى python-dev-owner > قبل 7 أيام > التفاصيل > > #While reading about functions in mathematics, a figure representing the sum > of two functions caught my attention. > #I found it w

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-05 Thread Chris Angelico
On Sat, Nov 6, 2021 at 2:57 AM Stephen J. Turnbull wrote: > Still on the agenda as far as I can see: > > 1. Syntax. The proposals I can recall are > a. x=>default > b. *x=default > c. x=@default > d. maybe putting * or @ on the opposite component in b and c? > e. a keyw

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-05 Thread Chris Angelico
On Sat, Nov 6, 2021 at 10:46 AM David Mertz, Ph.D. wrote: > > My "vote" if one has to be chosen: Preferences are very important. This isn't a "vote" in the sense that the one with the most choices will be selected, but I always want to hear people's preferences. > #1: x=defer default > #2: @x=

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-09 Thread Chris Angelico
On Wed, Nov 10, 2021 at 6:02 PM Christopher Barker wrote: > > On Mon, Nov 8, 2021 at 11:22 PM Rob Cliffe via Python-ideas > wrote: >> >> I have more than once advocated >> x:=default >> (and there is no clash with the walrus operator, even if others have >> said/implied that there is). > >

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-09 Thread Chris Angelico
On Wed, Nov 10, 2021 at 6:02 PM Christopher Barker wrote: > > On Mon, Nov 8, 2021 at 11:22 PM Rob Cliffe via Python-ideas > wrote: >> >> I have more than once advocated >> x:=default >> (and there is no clash with the walrus operator, even if others have >> said/implied that there is). > >

[Python-ideas] Re: Adding pep8-casing-compliant aliases for the entire stdlib

2021-11-11 Thread Chris Angelico
On Fri, Nov 12, 2021 at 12:41 AM Matt del Valle wrote: > 2) It's always been an extra thing to explain when teaching python to > someone. I always try to cover pep8 very early to discourage people I'm > training from internalizing bad habits, and it means you have to explain that > the very sta

[Python-ideas] Re: Adding pep8-casing-compliant aliases for the entire stdlib

2021-11-11 Thread Chris Angelico
On Fri, Nov 12, 2021 at 2:22 AM Matt del Valle wrote: >> >> ISTM that this indicates that you're putting too much focus on PEP 8 >> too early. At no time does the document ever state that all Python >> code ever written must comply with it. New Python programmers should >> not feel like they're be

[Python-ideas] Re: Python history [was Re: Re: Adding pep8-casing-compliant aliases for the entire stdlib]

2021-11-11 Thread Chris Angelico
On Fri, Nov 12, 2021 at 11:47 AM Steven D'Aprano wrote: > > I know this suggestion is withdrawn and the thread all but finished, but > for completion, I'd like to answer one of Chris' questions: > > On Fri, Nov 12, 2021 at 04:48:58AM +1100, Chris Angelico wrote:

[Python-ideas] Re: Allow syntax "func(arg=x if condition)"

2021-11-14 Thread Chris Angelico
On Mon, Nov 15, 2021 at 4:18 AM Peter O'Connor wrote: > > On Mon, Mar 22, 2021 at 1:28 PM Caleb Donovick > wrote: >> >> ... One could do something like: >> ``` >> def fun(a, b=0): ... >> def wraps_fun(args, b=inspect.signature(fun).parameters['b'].default): ... >> ``` >> But I would hardly call

[Python-ideas] Re: Allow syntax "func(arg=x if condition)"

2021-11-14 Thread Chris Angelico
On Mon, Nov 15, 2021 at 4:57 AM Christopher Barker wrote: > > On Sun, Nov 14, 2021 at 9:51 AM Chris Angelico wrote: >> >> Also, it's entirely possible that future >> versions of Python will have a concept of optional arguments that >> don't *have* de

[Python-ideas] Re: Make the global/nonlocal keyword a prefix

2021-11-14 Thread Chris Angelico
On Mon, Nov 15, 2021 at 5:05 AM Christopher Barker wrote: > > On Sun, Nov 14, 2021 at 6:05 AM Steven D'Aprano wrote: >> >> global a = 3 > > > The issue i see is that Python doesn't have declarations. So you could use > the name, a in multiple places. what would this mean: > > a = 34 > > glob

[Python-ideas] Re: Runtime-accessible attribute docstrings

2021-11-18 Thread Chris Angelico
On Thu, Nov 18, 2021 at 7:44 PM Stephen J. Turnbull wrote: > > Steven D'Aprano writes: > > On Wed, Nov 17, 2021 at 02:26:16PM -, tmkehrenb...@gmail.com wrote: > > > > > @dataclass > > > class A: > > > """Docstring for class A.""" > > > x: int > > > """Docstring for x""" > >

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-22 Thread Chris Angelico
On Tue, Nov 23, 2021 at 1:18 AM Remy wrote: > > Hi, I'd like to revive this thread after what seemed like a decade and see > where this might take us 😃 > > I like this idea that the OP suggested but I'd like to extend this to all > iterator objects (range_iterators, list_iterators etc.). > > 📌Id

[Python-ideas] Re: In consistent arguments: map v filter [was: Enhancing iterators ...]

2021-11-23 Thread Chris Angelico
On Tue, Nov 23, 2021 at 7:47 PM Stephen J. Turnbull wrote: > > Chris Angelico writes: > > > It's not too hard to create your own dataflow class if you want one. > > It can start with any arbitrary iterable, and then have your map and > > filter methods just t

[Python-ideas] Re: 'strict' for other itertools [was: Inconsistent arguments...]

2021-11-23 Thread Chris Angelico
On Wed, Nov 24, 2021 at 12:39 AM Stephen J. Turnbull wrote: > > Chris Angelico writes: > > On Tue, Nov 23, 2021 at 7:47 PM Stephen J. Turnbull > > wrote: > > > > There's also implementing zip's strict argument, eg, > > > > > > def z

[Python-ideas] Re: Should bare logical comparisons raise a warning?

2021-11-25 Thread Chris Angelico
On Fri, Nov 26, 2021 at 12:02 PM Rob Cliffe via Python-ideas wrote: > On 26/11/2021 00:12, Steven D'Aprano wrote: > > Personally, I think that this is the right design. People can pick and > > choose which, if any, linter they use, and how strict they want it to > > be. But I can also understand t

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-25 Thread Chris Angelico
On Fri, Nov 26, 2021 at 6:22 PM Abdulla Al Kathiri wrote: > > Chris, > > Will we able to use late-bound arguments in dataclass when it’s creating the > __init__ function? > > @dataclass > class C: > x: int > y: int > ls: list[int] => [x, y] > With that syntax, no, because there's no

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-26 Thread Chris Angelico
On Sat, Nov 27, 2021 at 1:39 AM Raimi bin Karim wrote: > So this is more of a heartfelt note rather than an objective one — I would > love > my fellow Python programmers to be exposed to this mental model, and that > could only be done by implementing it in the standard library. I'm not certain

[Python-ideas] Re: easier writing to multiple streams

2021-11-26 Thread Chris Angelico
On Sat, Nov 27, 2021 at 3:03 AM wrote: > > i wonder whether: > > from myutils import myprint as print > > or > > _print = print > print = myprint > > is really the pythonic way? Seems fine to me, what's unpythonic about it? > my use case for multiple files on top of the stdout, is when using e.g

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-27 Thread Chris Angelico
On Sat, Nov 27, 2021 at 10:52 PM Stephen J. Turnbull wrote: > > Raimi bin Karim writes: > > > 📌Proposed implementation > > Earlier in the thread, Chris proposed a custom class for this kind > > of pipeline. > > But what if we exposed this as a Python module in the standard library, > > parkin

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-28 Thread Chris Angelico
On Mon, Nov 29, 2021 at 5:54 AM Christopher Barker wrote: > > On Sun, Nov 28, 2021 at 9:30 AM Evpok Padding wrote: >> >> All apologies if it has been clarified earlier, but if you dislike nested >> method calls what is wrong with operating on generators as in >> >> ```pycon >> >>> itr = (i**2 fo

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-28 Thread Chris Angelico
On Mon, Nov 29, 2021 at 6:01 AM Christopher Barker wrote: > Hmm -- I jsut had a whacky idea: > > As pointed out, adding a bunch of chaining methods to the Iterator ABC isn't > really helpful, as it would A) potentially break / override existing classes > that happen to use teh same names, and B)

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-28 Thread Chris Angelico
On Mon, Nov 29, 2021 at 4:13 PM David Mertz, Ph.D. wrote: > > Or anyway, what would you call `bar := Bar()` if not "an iterator?! > A "broken iterator". ChrisA ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to pyt

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-29 Thread Chris Angelico
On Tue, Nov 30, 2021 at 4:39 AM Christopher Barker wrote: > > > > On Mon, Nov 29, 2021 at 2:12 AM Steven D'Aprano wrote: > >> Since most iterators don't have many methods, it's not clear to me that >> iterators are even a little bit relevant. > > > I think you just answered your own question. > >

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-30 Thread Chris Angelico
On Wed, Dec 1, 2021 at 9:09 AM Abdulla Al Kathiri wrote: > > How about using the typing return arrow -> to indicate the return of the > preceding goes as a first parameter in the function: > 1 -> add(2) That's a possibility. The same arrow then means "this function produces that value" in a defi

[Python-ideas] PEP 671 (late-bound arg defaults), next round of discussion!

2021-11-30 Thread Chris Angelico
I've just updated PEP 671 https://www.python.org/dev/peps/pep-0671/ with some additional information about the reference implementation, and some clarifications elsewhere. *PEP 671: Syntax for late-bound function argument defaults* Questions, for you all: 1) If this feature existed in Python 3.1

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-30 Thread Chris Angelico
On Wed, Dec 1, 2021 at 6:14 PM Abdulla Al Kathiri wrote: > > Thanks for the clarification. Yeah I agree it will look ugly if we use it not > as a first argument many times in a row but what if there is one or two > functions in the middle that they are not playing along and don’t have > teamwor

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 6:43 PM Abdulla Al Kathiri wrote: > > On 1 Dec 2021, at 10:16 AM, Chris Angelico wrote: > > 3) If "yes" to question 1, would you use it for any/all of (a) mutable > > defaults, (b) referencing things that might have changed, (c) > &g

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 7:07 PM Chris Angelico wrote: > > On Wed, Dec 1, 2021 at 6:58 PM Steven D'Aprano wrote: > > You say that now, but if you read function definitions that looked > > like this: > > > > def process(func:List->int=>xs=>expression)

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 6:58 PM Steven D'Aprano wrote: > > On Wed, Dec 01, 2021 at 07:47:49AM -, Jeremiah Vivian wrote: > > > > 2) Independently: Is the syntactic distinction between "=" and "=>" a > > > cognitive burden? > > No, it isn't much of a cognitive burden. > > You say that now, but if

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 7:12 PM Jeremiah Vivian wrote: > > > I'll reply to this comment once I've done so. > I just realized that this message replied on a comment instead of the thread. > Anyways, it's a really impressive implementation (hope this statement doesn't > spark some sort of debate).

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 7:35 PM Abdulla Al Kathiri wrote: > > > Sometimes when I do complicated regular expressions, I like to divide the > patterns from a big pattern to small patterns until I reach what I want. re > module functions take the text as a second argument. Furthermore, you can’t >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 8:18 PM Abdulla Al Kathiri wrote: > > > > > On 1 Dec 2021, at 12:01 PM, Chris Angelico wrote: > > > > On Wed, Dec 1, 2021 at 6:43 PM Abdulla Al Kathiri > > wrote: > >>> On 1 Dec 2021, at 10:16 AM, Chris Angelico wrote: >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 8:57 PM Neil Girdhar wrote: > > > > On Wednesday, December 1, 2021 at 1:18:33 AM UTC-5 Chris Angelico wrote: >> >> I've just updated PEP 671 https://www.python.org/dev/peps/pep-0671/ >> with some additional information about the re

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 9:09 PM Steven D'Aprano wrote: > > On Wed, Dec 01, 2021 at 07:07:20PM +1100, Chris Angelico wrote: > > > > def process(func:List->int=>xs=>expression)->int: > > > ... > > > I'm not sure what that'

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Wed, Dec 1, 2021 at 10:30 PM André Roberge wrote: > On Wed, Dec 1, 2021 at 2:17 AM Chris Angelico wrote: >> >> I've just updated PEP 671 https://www.python.org/dev/peps/pep-0671/ >> with some additional information about the reference implementation, >> a

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 12:42 AM David Mertz, Ph.D. wrote: >> 4) If "no" to question 1, is there some other spelling or other small >> change that WOULD mean you would use it? (Some examples in the PEP.) > > > Yes, the delay/later/defer keyword approach is not confusing, and does not > preempt a l

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 1:21 AM Paul Moore wrote: > > On Wed, 1 Dec 2021 at 06:19, Chris Angelico wrote: > > 3) If "yes" to question 1, would you use it for any/all of (a) mutable > > defaults, (b) referencing things that might have changed, (c) > > referencing o

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 2:24 AM David Mertz, Ph.D. wrote: > > On Wed, Dec 1, 2021 at 9:24 AM Paul Moore wrote: >> >> I think that the only >> thing I might use it for is to make it easier to annotate defaults (as >> f(a: list[int] => []) rather than as f(a: list[int] | None = None). > > > Why not

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 1:33 AM André Roberge wrote: > On Wed, Dec 1, 2021 at 7:51 AM Chris Angelico wrote: >> >> On Wed, Dec 1, 2021 at 10:30 PM André Roberge >> wrote: >> >> >> 2) Independently: Is the syntactic distinction between "=" and &qu

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 2:47 AM David Lukeš wrote: > > This was probably mentioned at some point (apologies, can't afford to > read the entire thread), but since the issue of left-to-right vs. > early-first-then-late binding was hotly debated, I just want to point out > that left-to-right better pr

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 2:40 AM David Mertz, Ph.D. wrote: > > On Wed, Dec 1, 2021 at 10:12 AM Chris Angelico wrote: >> >> On Thu, Dec 2, 2021 at 12:42 AM David Mertz, Ph.D. >> wrote: >> >> 4) If "no" to question 1, is there some other spelling o

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 4:40 AM Barry Scott wrote: > > On 1 Dec 2021, at 06:16, Chris Angelico wrote: > 3) If "yes" to question 1, would you use it for any/all of (a) mutable > defaults, (b) referencing things that might have changed, (c) > referencing other argu

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 8:50 AM Barry Scott wrote: > > > > > On 1 Dec 2021, at 17:59, Chris Angelico wrote: > > > > On Thu, Dec 2, 2021 at 4:40 AM Barry Scott wrote: > >> > >> On 1 Dec 2021, at 06:16, Chris Angelico wrote: > >> 3) If &

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 12:42 PM David Lukeš wrote: > > > That's an oversimplification: > > > > foo = 42 > > def bar(): > > print(foo) > > foo = 1 > > > > This won't print 42. > > Oh, right. I've run afoul of this in the past, but clearly not often > enough to make it second nature :) Thank

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 1:30 PM Steven D'Aprano wrote: > > On Wed, Dec 01, 2021 at 12:26:33PM +, Matt del Valle wrote: > > > If anything I think > > the symmetry between the proposed '=>' syntax and the arrow syntax for > > lambdas in other languages (potentially even in python in the future) >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 6:12 PM wrote: > > Brendan Barnwell wrote: > > > No. As I mentioned in the earlier thread, I don't support any proposal > > in which an argument can "have a default" but that default is not a > > first-class Python object of some sort. > > What if a default is a function? >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-01 Thread Chris Angelico
On Thu, Dec 2, 2021 at 6:27 PM Brendan Barnwell wrote: > > On 2021-12-01 18:35, Chris Angelico wrote: > > In my reference implementation, there is no object that stores it; > > it's simply part of the function. A good parallel is the if/else > > expression: > >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Thu, Dec 2, 2021 at 6:59 PM Brendan Barnwell wrote: > > On 2021-12-01 23:36, Chris Angelico wrote: > > That's exactly why it's such a close parallel. The late-evaluated > > default is just code, nothing else. It's not "stored" in any way - it > &g

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Thu, Dec 2, 2021 at 7:31 PM Paul Moore wrote: > > On Wed, 1 Dec 2021 at 22:27, Greg Ewing wrote: > > > > On 2/12/21 4:40 am, Paul Moore wrote: > > > the > > > intended use is that people must supply a list[int] or not supply the > > > argument *at all*. > > > > I don't think this is a style of

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Thu, Dec 2, 2021 at 7:36 PM Paul Moore wrote: > > Actually, Chris - does functools.wraps work properly in your > implementation when wrapping functions with late-bound defaults? > > >>> def dec(f): > ... @wraps(f) > ... def inner(*args, **kw): > ... print("Calling") > ...

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Thu, Dec 2, 2021 at 8:40 PM Steven D'Aprano wrote: > Depending on the implementation, you *might* be able to inspect the > function and see the default expression as some sort of callable > function, or evaluatable code object. (That would be nice.) Unfortunately not, since the default express

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 12:43 AM David Mertz, Ph.D. wrote: > > On Thu, Dec 2, 2021 at 3:33 AM Chris Angelico wrote: >> >> > But it IS stored! There is no way for it to be evaluated without >> > it >> > being stored! >> > >> I&#

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 1:53 AM Steven D'Aprano wrote: > > On Thu, Dec 02, 2021 at 11:00:33PM +1100, Chris Angelico wrote: > > On Thu, Dec 2, 2021 at 8:40 PM Steven D'Aprano wrote: > > > Depending on the implementation, you *might* be able to inspect the >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 2:11 AM Rob Cliffe via Python-ideas wrote: > > > > On 02/12/2021 14:47, Steven D'Aprano wrote: > > On Thu, Dec 02, 2021 at 11:00:33PM +1100, Chris Angelico wrote: > > I'm still unsure whether this is a cool feature or an

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 2:17 AM Steven D'Aprano wrote: > > On Wed, Dec 01, 2021 at 09:58:11PM -0600, Abe Dillon wrote: > > > My favorite alternative is ?= if people think => and -> are getting > > overly loaded. What I really don't like is @param=[] because it puts the > > emphasis on the paramet

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 4:22 AM Nicholas Cole wrote: > There is nothing that this proposal makes possible that is not already > possible with more explicit code. It's worth noting that "explicit" does not mean "verbose". For instance, this is completely explicit about what it does: x += 1 It doe

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 6:24 AM Brendan Barnwell wrote: > What I'm saying is that I want that "thing" to exist. At the time the > function is defined, I want there to be a Python object which represents > the behavior to be activated at call time if the argument is not passed. > In the c

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 6:50 AM Oscar Benjamin wrote: > > On Thu, 2 Dec 2021 at 17:28, Chris Angelico wrote: > > > > On Fri, Dec 3, 2021 at 4:22 AM Nicholas Cole > > wrote: > > > There is nothing that this proposal makes possible that is not already >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 7:54 AM Eric V. Smith wrote: > > On 12/2/2021 2:21 PM, Brendan Barnwell wrote: > > On 2021-12-02 01:35, Steven D'Aprano wrote: > > >4) If "no" to question 1, is there some other spelling or other > small > > >change that WOULD mean you would use it? (Some exam

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 8:07 AM David Mertz, Ph.D. wrote: > > On Thu, Dec 2, 2021 at 2:40 PM Chris Angelico wrote: >> >> How is a late-bound default different from half of a conditional expression? > > >> >> def f(lst=>[], n=>len(lst)): >> >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 9:26 AM Brendan Barnwell wrote: > > On 2021-12-02 00:31, Chris Angelico wrote: > > Here's how a ternary if looks: > > > >>>> >>>def f(n): > > ... return 0 if n == 0 else 42/n > > ... > >>

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 12:48 PM Steven D'Aprano wrote: > > On Fri, Dec 03, 2021 at 02:10:12AM +1100, Chris Angelico wrote: > > > > > Unfortunately not, since the default expression could refer to other > > > > parameters, or closure variables, or anythin

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 2:27 PM Steven D'Aprano wrote: > > On Fri, Dec 03, 2021 at 10:36:55AM +1100, Chris Angelico wrote: > > > Same again. If you consider the equivalent to be a line of code in the > > function body, then the signature has become MASSIVELY more use

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 2:24 PM Steven D'Aprano wrote: > > On Fri, Dec 03, 2021 at 01:08:50PM +1100, Chris Angelico wrote: > > > How, with external calling, are you going to know which name > > references to look up, and where to get their values from? > > Isn&

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 2:30 PM Brendan Barnwell wrote: > > On 2021-12-02 15:40, Chris Angelico wrote: > > Actually, no. I want to put the default arguments into the signature, > > and the body in the body. The distinction currently has a technical > > restriction tha

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-02 Thread Chris Angelico
On Fri, Dec 3, 2021 at 3:47 PM Abe Dillon wrote: > This seems like an exceedingly minor complaint. The obvious answer is: you > invoke the default behaviour by not passing the argument. And yes, I know > that's less explicit, but that's kinda the whole point of defaults to begin > with. It's be

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-03 Thread Chris Angelico
On Sat, Dec 4, 2021 at 3:47 AM Andrew Jaffe wrote: > b) I think another motivation that hasn't been highlighted is teaching > -- perhaps surprisingly, I think adding this will make some aspects of > teaching *easier*. Mutable defaults are known to be confusing to Python > neophytes; I have certain

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-03 Thread Chris Angelico
On Sat, Dec 4, 2021 at 4:48 AM Eric V. Smith wrote: > > On 12/2/2021 6:36 PM, Chris Angelico wrote: > > On Fri, Dec 3, 2021 at 7:54 AM Eric V. Smith wrote: > >> > >> Say I have a function with an early-bound default. I can inspect it and > >> I can change

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-03 Thread Chris Angelico
On Sat, Dec 4, 2021 at 8:18 AM Rob Cliffe via Python-ideas wrote: > > > > On 03/12/2021 19:32, Adam Johnson wrote: > > > > The first unwelcome surprise was: > > > > >>> def func(a=>[]): > > ... return a > > ... > > > > >>> import inspect > > >>> inspect.signature(func)

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-03 Thread Chris Angelico
On Sat, Dec 4, 2021 at 6:33 AM Adam Johnson wrote: > > 5) Do you know how to compile CPython from source, and would you be > > willing to try this out? Please? :) > > I have. > > The first unwelcome surprise was: > > >>> def func(a=>[]): > ... return a > ... > > >>> import insp

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-03 Thread Chris Angelico
On Sat, Dec 4, 2021 at 11:59 AM Rob Cliffe via Python-ideas wrote: > > > > On 03/12/2021 22:38, Chris Angelico wrote: > > On Sat, Dec 4, 2021 at 8:18 AM Rob Cliffe via Python-ideas > > wrote: > >> > >> > >> On 03/12/2021 19:32, Adam Jo

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-03 Thread Chris Angelico
On Sat, Dec 4, 2021 at 2:52 PM Rob Cliffe via Python-ideas wrote: > > > > On 04/12/2021 01:06, Chris Angelico wrote: > > On Sat, Dec 4, 2021 at 11:59 AM Rob Cliffe via Python-ideas > > wrote: > >> > >> > >> On 03/12/2021 22:38, Chris Angel

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-03 Thread Chris Angelico
On Sat, Dec 4, 2021 at 2:34 PM Steven D'Aprano wrote: > > On Fri, Dec 03, 2021 at 10:40:42AM +1100, Chris Angelico wrote: > > > Here's what you get: > > > > >>> def f(lst=>[], n=>len(lst)): ... > > ... > > >>> f.__defaults_

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-04 Thread Chris Angelico
On Sat, Dec 4, 2021 at 8:48 PM Steven D'Aprano wrote: > > On Sat, Dec 04, 2021 at 03:14:46PM +1100, Chris Angelico wrote: > > > Lots and lots and lots of potential problems. Consider: > > > > def f(): > > a = 1 > > def f(b, x=>a+b): > >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 6:16 AM Brendan Barnwell wrote: > > On 2021-12-04 03:50, Chris Angelico wrote: > > On Sat, Dec 4, 2021 at 8:48 PM Steven D'Aprano wrote: > >> And third, when the interpreter fetches a default from > >> func.__defaults__, if it is a LB fu

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 5:29 AM Barry Scott wrote: > > > > > On 1 Dec 2021, at 06:16, Chris Angelico wrote: > > > > I've just updated PEP 671 https://www.python.org/dev/peps/pep-0671/ > > with some additional information about the reference implementation,

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 11:34 AM Steven D'Aprano wrote: > > On Sat, Dec 04, 2021 at 10:50:14PM +1100, Chris Angelico wrote: > > > > syntactic sugar for this: > > > > > > def f(b, x=lambda b: a+b): ... > > > > > > except that the lambda

[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 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 (late-bound arg defaults), next round of discussion!

2021-12-04 Thread Chris Angelico
On Sun, Dec 5, 2021 at 3:08 PM Stephen J. Turnbull wrote: > > Barry Scott writes: > > > There are many possible implementation of the late bound idea that > > could create an object/default expression. > > But is it reasonable to bother with that added > > complexity/maintenance burden for a f

[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 > >

[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 a

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Sun, Dec 5, 2021 at 5:41 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > Also FWIW, I still think that if you're doing (b) or (c), then you're > *not* doing default values anymore, you're moving pieces of the logic or > the design into the wrong place. One example of (b) goes something like >

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Sun, Dec 5, 2021 at 9:58 PM Barry Scott wrote: >> def inner(timestamp=>time.time()): > >if timestamp is None: timestamp = time.time() > > > And, obviously, if you end up needing the write the explicit check for None > there is no > advantage to using late bound default. Hmm, I wouldn't s

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Mon, Dec 6, 2021 at 1:45 AM Steven D'Aprano wrote: > > On Sat, Dec 04, 2021 at 06:11:08PM +, Barry Scott wrote: > > > There are many possible implementation of the late bound idea that > > could create an object/default expression. But is it reasonable to > > bother with that added complexi

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Mon, Dec 6, 2021 at 1:48 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2021-12-05 at 20:30:53 +1100, > Chris Angelico wrote: > > > On Sun, Dec 5, 2021 at 5:41 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > > Also FWIW, I still think that

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Mon, Dec 6, 2021 at 2:56 AM Steven D'Aprano wrote: > > > What sort of "behave differently" do you think would prevent us from > > > introspecting the function object? "Differently" from what? > > > > Wrapping it in a function means the walrus would assign in that > > function's context, not the

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Mon, Dec 6, 2021 at 4:13 AM Steven D'Aprano wrote: > > On Mon, Dec 06, 2021 at 02:08:46AM +1100, Chris Angelico wrote: > > > I want to have them syntactically as part of the body > > of the function, and semantically as part of the function call. > > Then you

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Mon, Dec 6, 2021 at 5:20 AM Christopher Barker wrote: > > On Sun, Dec 5, 2021 at 3:28 AM Chris Angelico wrote: >> >> (That said, though: it would be rather nice to be able to do algebra >> with function signatures. For instance, you could say "my signature is &

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Mon, Dec 6, 2021 at 5:38 AM David Mertz, Ph.D. wrote: > > On Sun, Dec 5, 2021, 12:33 PM Chris Angelico >> >> And quite frankly, the tone of this list is sounding like "shut up, go away, >> don't do anything, because there are other proposals that nobody can

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Chris Angelico
On Mon, Dec 6, 2021 at 5:51 AM David Mertz, Ph.D. wrote: > > On Sun, Dec 5, 2021, 1:48 PM Chris Angelico >> >> You: "Keep the status quo, all done" >> Also you: "Let's wait for something better" > > > Now is better than never. > Altho

<    1   2   3   4   5   6   7   8   9   10   >