[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread Paul Sokolovsky
Hello, On Sun, 14 Feb 2021 18:36:14 +1100 Steven D'Aprano wrote: > On Thu, Feb 11, 2021 at 09:36:25PM -0800, Guido van Rossum wrote: > > > Agreed. I'd prefer the JavaScript solution, since -> already has a > > different meaning in Python return *type*. We could use -> to > > simplify typing.Cal

[Python-ideas] Re: Arrow functions polyfill

2021-02-14 Thread Paul Sokolovsky
Hello, On Sun, 14 Feb 2021 13:57:14 +1100 Steven D'Aprano wrote: > On Sun, Feb 14, 2021 at 12:47:30AM +0300, Paul Sokolovsky wrote: > > Hello, > > > > On Sat, 13 Feb 2021 16:25:24 -0500 > > Cade Brown wrote: > > > > > In my humble opinion, arrows should be '->' instead of '=>'. It > > > alw

[Python-ideas] Re: Arrow functions polyfill

2021-02-14 Thread Steven D'Aprano
On Sun, Feb 14, 2021 at 11:54:21AM +0300, Paul Sokolovsky wrote: > > > b) Python already uses "->" for function return *type*. And there's > > > idea to generalize it to *function type* in general. E.g. a function > > > "(a, b) => a + b" can have type "(int, int) -> int". > > > > This supports

[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread anthony.flury via Python-ideas
On 12/02/2021 07:32, Paul Sokolovsky wrote: Hello, On Fri, 12 Feb 2021 18:26:53 +1100 Chris Angelico wrote: On Fri, Feb 12, 2021 at 6:24 PM Paul Sokolovsky wrote: ... And on the 2nd thought, that won't work. The reason it works in JS is that it doesn't have tuples. In Python, "(a, b) => (

[Python-ideas] Re: Pattern Matching -- Removing Name Binding from Partial Matching

2021-02-14 Thread Abdulla Al Kathiri
My idea was that in the case of partial matching or full matching without passing the guard, the binding names has some sort of self destruction and return to the previous state. Using different variable names would resolve the issue and if I want to modify the global variables, I could choose t

[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread Serhiy Storchaka
11.02.21 13:24, J. Pic пише: > Lambdas can be defined as such: > > w = lambda: [12] > x = lambda y: len(y) > > I'd like to propose the following: > > w = (): [12] > x = (y): len(y) This syntax is ambiguous. if (y): len(y): What does the first colon mean? You cannot say until you read the

[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread Abdulla Al Kathiri
def func(x: int, y: int, f: (int, int) -> int) -> int: return f(x, y) print(func(1, 4, (x, y) -> x + y)) #Output: 5 I think we can still use the same syntax for both typing.Callable and lambda. It would act like Callable if it comes after the “:” in annotations or after the “-

[Python-ideas] Re: Arrow functions polyfill

2021-02-14 Thread Chris Angelico
On Sun, Feb 14, 2021 at 8:42 PM Steven D'Aprano wrote: > We should not choose the more confusing, error-prone solution out of > fear of being different. Python is already different from Javascript in > every regard: > Is it really? > - the basic execution model is different; Don't know what you

[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread Steven D'Aprano
On Sun, Feb 14, 2021 at 11:23:59AM +0300, Paul Sokolovsky wrote: > > We've seen Paul mistake => for >= and he's not the only one. > > Well, my mistake is based on the fact that I don't spend high-level > neurons on remembering mundane low-level things, like order of > characters if the "greater o

[Python-ideas] Re: Pattern Matching -- Removing Name Binding from Partial Matching

2021-02-14 Thread Chris Angelico
On Sun, Feb 14, 2021 at 11:26 PM Abdulla Al Kathiri wrote: > > My idea was that in the case of partial matching or full matching without > passing the guard, the binding names has some sort of self destruction and > return to the previous state. Using different variable names would resolve > th

[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread Steven D'Aprano
Be bold, they say... On Mon, Feb 15, 2021 at 02:13:38AM +1100, Steven D'Aprano wrote: > If I'm wrong, I'm sure somebody will point that out. I'm not frightened > of making bold claims that turn out to be wrong: that just means I have > learned something new. (Or something old that I forgot.)

[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread Paul Sokolovsky
Hello, On Sat, 13 Feb 2021 14:33:43 -0800 Christopher Barker wrote: > There seems to be a frequent objection to the word "lambda" -- > personally, I found it cryptic, but it's not hard to remember, and it > IS easy to look up. There seems to be a bit too many posts downputting the "lambda" keyw

[Python-ideas] Re: Conditional with statements

2021-02-14 Thread Rob Cliffe via Python-ideas
On 14/02/2021 02:23, Christopher Barker wrote: Thanks Rob. You've broken a number of "rules" code code formatting there ;-) Thanks for the quotation marks.  Indeed, PEP 8 provides guidelines, not diktats. A big one is aligning things vertically, which, as a rule, I like. but this example doe

[Python-ideas] Re: Alternate lambda syntax

2021-02-14 Thread Christopher Barker
On Sun, Feb 14, 2021 at 4:26 AM Serhiy Storchaka wrote: > Lambda is a questionable feature at all. With support of comprehensions, > local functions, the operator and functools modules there are not many > use cases for lambda expression. They are supported, well, but it is not > significant part

[Python-ideas] Re: Pattern Matching -- Removing Name Binding from Partial Matching

2021-02-14 Thread Abdulla Al Kathiri
That makes sense. As Guido mentioned, this is similar to reusing a variable in a for-loop. You do it at your own risk. Ok consider me convinced. I will use the following sentence to explain name binding in partial matching: “Match statements are liable to any or all names bound in any of the patt

[Python-ideas] Re: Pattern Matching -- Removing Name Binding from Partial Matching

2021-02-14 Thread Guido van Rossum
I should add that I accidentally left out a word. It should be “... liable to *overwrite* any or all names ...” On Sun, Feb 14, 2021 at 12:10 Abdulla Al Kathiri < alkathiri.abdu...@gmail.com> wrote: > That makes sense. As Guido mentioned, this is similar to reusing a > variable in a for-loop. You

[Python-ideas] Pattern-Matching for functions

2021-02-14 Thread Abdulla Al Kathiri
In some functional programming languages, they can pattern match a function based on its parameters. Similar to function overloading. Will Python Pattern Matching do something similar to functions? If calling a function doesn't match any of the cases and catch-all case is not present, then some

[Python-ideas] Re: Conditional with statements

2021-02-14 Thread Steven D'Aprano
On Mon, Feb 08, 2021 at 02:45:57AM -0500, David Mertz wrote: > I don't like the actual proposal. It weirdly combines almost orthogonal > concepts into the same block statement. I'm curious why you say that if and with are "almost" orthogonal concepts? They seem completely orthogonal to me. You c

[Python-ideas] Re: Arrow functions polyfill

2021-02-14 Thread Brendan Barnwell
On 2021-02-14 00:54, Paul Sokolovsky wrote: There're 2 things about that from an experienced JavaScript-hater (but a pragmatic guy otherwise): 1. We aren't talking about all of JavaScript, but a recent features added to JS. 2. JS has real money being poured into it, and no longer designed on two

[Python-ideas] Re: Conditional with statements

2021-02-14 Thread Christopher Barker
Getting OT here -- you've been warned. On Sun, Feb 14, 2021 at 2:10 AM Rob Cliffe wrote: > You've broken a number of "rules" code code formatting there ;-) > > Thanks for the quotation marks. Indeed, PEP 8 provides guidelines, not > diktats. > > A big one is aligning things vertically, which, a

[Python-ideas] Re: Arrow functions polyfill

2021-02-14 Thread Steven D'Aprano
On Sun, Feb 14, 2021 at 01:31:29AM -0500, Random832 wrote: > > http://www.rosettacode.org/wiki/Function_definition > > That page doesn't really do well at explaining lambda expressions > specifically, omitting it for some languages that definitely have them > [such as Dart]. It's a community s

[Python-ideas] Re: Arrow functions polyfill

2021-02-14 Thread Chris Angelico
On Mon, Feb 15, 2021 at 5:28 PM Steven D'Aprano wrote: > In the first case, => will forever be fighting against the much stronger > memory trace of >= (I think we can agree that comparisons will be more > common than anonymous functions). People's muscle-memory will type >= > when they want the ar

[Python-ideas] Re: Conditional with statements

2021-02-14 Thread David Mertz
On Sun, Feb 14, 2021, 5:46 PM Steven D'Aprano wrote: > I'm curious why you say that if and with are "almost" orthogonal concepts? > They seem completely orthogonal to me. You can mix and match them in > literally every combination: > I mean in a conceptual sense, not as a matter of Python gramma