RE: New assignmens ...

2021-10-29 Thread Avi Gross via Python-list
ist@python.org Subject: Re: New assignmens ... Op 28/10/2021 om 19:36 schreef Avi Gross via Python-list: > Now for a dumb question. Many languages allow a form of setting a variable to > a value like: > > > > assign(var, 5+sin(x)) > > > > If we

Re: New assignmens ...

2021-10-29 Thread Antoon Pardon
Op 28/10/2021 om 19:36 schreef Avi Gross via Python-list: Now for a dumb question. Many languages allow a form of setting a variable to a value like: assign(var, 5+sin(x)) If we had a function that then returned var or the value of var, cleanly, then would that

Re: New assignmens ...

2021-10-29 Thread Antoon Pardon
Op 28/10/2021 om 19:36 schreef Avi Gross via Python-list: Antoon, You keep beating a dead horse. NOBODY denies there are benefits to suggestions like the one we are describing. It is a logical fallacy to keep arguing this way. Please point to the specific logical falacy you think I am

Re: New assignmens ...

2021-10-28 Thread Chris Angelico
On Fri, Oct 29, 2021 at 4:37 AM Avi Gross via Python-list wrote: > Now for a dumb question. Many languages allow a form of setting a variable to > a value like: > > assign(var, 5+sin(x)) > > If we had a function that then returned var or the value of var, cleanly, > then would

RE: New assignmens ...

2021-10-28 Thread Avi Gross via Python-list
ect: Re: New assignmens ... Op 27/10/2021 om 20:20 schreef Avi Gross: I think anyone who suggests we should separate costs from benefits belongs securely within the academic world and should remain there. Practical things need to be built considering costs. Theoretical things, sure, c

Re: New assignmens ...

2021-10-28 Thread Jon Ribbens via Python-list
On 2021-10-28, Paul Rubin wrote: > Chris Angelico writes: >> But it all depends on the exact process being done, which is why I've >> been asking for real examples. > > My most frequent use case for walrus is so common that I have sometimes > implemented a special class for it: > >if g :=

Re: New assignmens ...

2021-10-28 Thread Antoon Pardon
Op 27/10/2021 om 17:05 schreef Christman, Roger Graydon: I'm going to provide two loop-and-a-half segments to illustrate my interpretation of this PEP and the purpose of the walrus operator: [ first example ] Now contrast with this example: Without the walrus: replay = True while replay:

Re: New assignmens ...

2021-10-28 Thread Antoon Pardon
Op 27/10/2021 om 20:20 schreef Avi Gross: I think anyone who suggests we should separate costs from benefits belongs securely within the academic world and should remain there. Practical things need to be built considering costs. Theoretical things, sure, cost is not an issue. Seperating

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 11:08 AM Avi Gross via Python-list wrote: > > Dave, > > You make me wonder about unintended side effects. Are we allowing the ++ and > --- operations into Python through a side door? > class IncrementableInteger(int): def __pos__(self): return HalfIncremented(self)

RE: New assignmens ...

2021-10-27 Thread Avi Gross via Python-list
Of dn via Python-list Sent: Wednesday, October 27, 2021 4:38 AM To: python-list@python.org Subject: Re: New assignmens ... On 24/10/2021 22.23, O365 Dict wrote: > Well I have the following use case: > > while (temp_result := calculate_next_couple(a, b))[1]: > a, b =

Re: New assignmens ...

2021-10-27 Thread Abdur-Rahmaan Janhangeer
I no longer track the threads on the subject ... Many simultaneous ones ongoing! Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius --

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 4:34 AM Christman, Roger Graydon wrote: > Do you put special code in next_couple() to recognize that the provided > arguments > are actually the first couple so it can return those unmodified, but then > require its > own mental note not to give you an infinite loop

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Thu, Oct 28, 2021 at 4:03 AM Antoon Pardon wrote: > > So suppose I have an arbitrary number of simple statements. The > latter possible using results from previous assignment and at the > end a condition to control the one and a half loop. How do you write > the python code so that the one and

RE: New assignmens ...

2021-10-27 Thread Avi Gross via Python-list
the walrus and like it and it makes coding easier AND they ask for more, it may come, at incremental cost. -Original Message- From: Python-list On Behalf Of Antoon Pardon Sent: Wednesday, October 27, 2021 2:59 AM To: python-list@python.org Subject: Re: New assignmens ... Op 26/10/2021 om

Re: New assignmens ...

2021-10-27 Thread Christman, Roger Graydon
On 27/10/2021 8:28, Anton Pardon wrote: >>> Suppose I would like to write a loop as follows: >>. >while ((a, b) := next_couple(a, b))[1]: >> >do needed calculations >> >> >>> What I can do is write it as follows: >>> while [tmp := next_couple(a,b), a := tmp[0], b :=

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 27/10/2021 om 18:16 schreef Christman, Roger Graydon: On 27/10/2021 at 12:45 Antoon Pardon wrote: However with the introduction of the walrus operator there is a way to simulate a significant number of one and a half loops. Consider the following: >do > a = expr1 >

Re: New assignmens ...

2021-10-27 Thread Christman, Roger Graydon
On 27/10/2021 at 12:45 Antoon Pardon wrote: > However with the introduction of the walrus operator there is a > way to simulate a significant number of one and a half loops. > Consider the following: >do > a = expr1 > b = expr2 > while 2 * a > b: > more calculations

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 27/10/2021 om 11:59 schreef Chris Angelico: You can argue the word "need" all you like, but the fact remains that YOU want a change, so YOU have to convince people of the benefits. That is true. But there is nothing wrong in asking what might convince people. But I'll give you my thought

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 8:20 PM Antoon Pardon wrote: > > > > Op 27/10/2021 om 10:49 schreef Chris Angelico: > > On Wed, Oct 27, 2021 at 7:46 PM Antoon Pardon wrote: > >>> So if you want this added, show a use-case that makes it look way > >>> better than the alternatives (including a generator,

Re: New assignmens ...

2021-10-27 Thread Peter J. Holzer
On 2021-10-24 11:23:48 +0200, O365 Dict wrote: > do: > a, b = calculate_next_couple(a, b) > while b: > more calculations I actually like that syntax. -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at

Re: New assignmens ...

2021-10-27 Thread Peter J. Holzer
On 2021-10-27 19:05:52 +1100, Chris Angelico wrote: > On Wed, Oct 27, 2021 at 6:00 PM Antoon Pardon wrote: > > while (a, b) := next_couple(a,b)[-1]: > > ... [...] > I'm not sure that it's much of a use-case; isn't it an infinite loop as > written? > > And that's the problem. With

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 27/10/2021 om 10:49 schreef Chris Angelico: On Wed, Oct 27, 2021 at 7:46 PM Antoon Pardon wrote: So if you want this added, show a use-case that makes it look way better than the alternatives (including a generator, a mid-loop break, etc). Way better according to which criteria? IMO to

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 27/10/2021 om 10:38 schreef dn via Python-list: On 24/10/2021 22.23, O365 Dict wrote: Well I have the following use case: while (temp_result := calculate_next_couple(a, b))[1]: a, b = temp_result more calculations Which IMO would be clearer if I could just write:

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 7:39 PM dn via Python-list wrote: > Accordingly: is this a job for the walrus operator at all? Let's "talk > of many [other] things"*. +1 > Could we use a data structure to continue to keep things straight-forward? > > class my_class(): > def __init__( self, a, b

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 7:46 PM Antoon Pardon wrote: > > So if you want this added, show a use-case that makes it look way > > better than the alternatives (including a generator, a mid-loop break, > > etc). > > Way better according to which criteria? IMO to realy make something like > this you

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 27/10/2021 om 10:05 schreef Chris Angelico: On Wed, Oct 27, 2021 at 6:00 PM Antoon Pardon wrote: Op 26/10/2021 om 00:24 schreef Chris Angelico: TBH, I don't think there's a lot of value in multiple-assignment, since it has a number of annoying conflicts of syntax and few viable

Re: New assignmens ...

2021-10-27 Thread dn via Python-list
On 24/10/2021 22.23, O365 Dict wrote: > Well I have the following use case: > > while (temp_result := calculate_next_couple(a, b))[1]: > a, b = temp_result > more calculations > > Which IMO would be clearer if I could just write: > > while ((a, b) :=

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 27/10/2021 om 10:05 schreef Chris Angelico: On Wed, Oct 27, 2021 at 6:00 PM Antoon Pardon wrote: Op 26/10/2021 om 00:24 schreef Chris Angelico: TBH, I don't think there's a lot of value in multiple-assignment, since it has a number of annoying conflicts of syntax and few viable

Re: New assignmens ...

2021-10-27 Thread Chris Angelico
On Wed, Oct 27, 2021 at 6:00 PM Antoon Pardon wrote: > > > > Op 26/10/2021 om 00:24 schreef Chris Angelico: > > TBH, I don't think there's a lot of value in multiple-assignment, > > since it has a number of annoying conflicts of syntax and few viable > > use-cases. But if you have great examples

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 26/10/2021 om 00:24 schreef Chris Angelico: TBH, I don't think there's a lot of value in multiple-assignment, since it has a number of annoying conflicts of syntax and few viable use-cases. But if you have great examples of "x.y :=" or "x[y] :=", then by all means, post on python-ideas to

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 26/10/2021 om 19:46 schreef Schachner, Joseph: Why force unpacking? Why not assign a tuple? That would look like a simple assignment: x := (alpha, beta, gamma) And you could access x[0], x[1] and x[2]. I think asking := to support x, y := alpha, beta is a request to address an

Re: New assignmens ...

2021-10-27 Thread Antoon Pardon
Op 25/10/2021 om 18:47 schreef Christman, Roger Graydon: Message: 8 Date: Mon, 25 Oct 2021 11:20:52 +0200 From: Antoon Pardon To: python-list@python.org Subject: Re: New assignmens ... Message-ID: <5761dd65-4e87-8b8c-1400-edb821204...@vub.be> Content-Type: text/plain; charset=utf-8;

RE: New assignmens ...

2021-10-26 Thread Schachner, Joseph
. And as previously pointed out you can still just use = . --- Joseph S. Teledyne Confidential; Commercially Sensitive Business Data -Original Message- From: Chris Angelico Sent: Monday, October 25, 2021 6:25 PM To: Python Subject: Re: New assignmens ... On Tue, Oct 26, 2021 at 9:19 AM dn via

Re: New assignmens ...

2021-10-26 Thread Antoon Pardon
Op 25/10/2021 om 23:03 schreef Chris Angelico: > On Tue, Oct 26, 2021 at 7:18 AM Antoon Pardon wrote: >> Op 25/10/2021 om 20:39 schreef Chris Angelico: >>> On Tue, Oct 26, 2021 at 5:35 AM Antoon Pardon wrote: By putting limits on the walrus code, you are not reducing complexity, you

RE: New assignmens ...

2021-10-25 Thread Avi Gross via Python-list
thon-list On Behalf Of Stefan Ram Sent: Monday, October 25, 2021 12:57 PM To: python-list@python.org Subject: Re: New assignmens ... "Avi Gross" writes: >Now, yes, nobody needs a function to just add two numbers. If one uses a framework like "functools.reduce", the only way

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 9:19 AM dn via Python-list wrote: > Back on-topic, I am slightly curious:- > > aside from 'starting small' with an option to widen/'open-up' later, is > there a particular reason why 'the walrus' has not been made available > (could not be ...?) for use with

Re: New assignmens ...

2021-10-25 Thread dn via Python-list
On 26/10/2021 10.45, Chris Angelico wrote: > On Tue, Oct 26, 2021 at 8:42 AM Avi Gross via Python-list > wrote: >> Personally, I don't care what is done and suspect I will rarely feel much >> need to use the current walrus operator, let alone an enhanced Odobenus >> rosmarus operator like ::==

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 8:42 AM Avi Gross via Python-list wrote: > Personally, I don't care what is done and suspect I will rarely feel much > need to use the current walrus operator, let alone an enhanced Odobenus > rosmarus operator like ::== ... > . wait what? Ah. Had to look that one

RE: New assignmens ...

2021-10-25 Thread Avi Gross via Python-list
Odobenus rosmarus operator like ::== ... -Original Message- From: Python-list On Behalf Of Christman, Roger Graydon Sent: Monday, October 25, 2021 12:48 PM To: python-list@python.org Subject: Re: New assignmens ... Message: 8 Date: Mon, 25 Oct 2021 11:20:52 +0200 From: Antoon Pardon

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 7:18 AM Antoon Pardon wrote: > > Op 25/10/2021 om 20:39 schreef Chris Angelico: > > On Tue, Oct 26, 2021 at 5:35 AM Antoon Pardon wrote: > >> By putting limits on the walrus code, you are not reducing complexity, you > >> are increasing it. > >> You are increasing

Re: New assignmens ...

2021-10-25 Thread Antoon Pardon
Op 25/10/2021 om 20:39 schreef Chris Angelico: > On Tue, Oct 26, 2021 at 5:35 AM Antoon Pardon wrote: >> By putting limits on the walrus code, you are not reducing complexity, you >> are increasing it. >> You are increasing complexity because you can't just reuse the code that >> handles an

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 5:35 AM Antoon Pardon wrote: > By putting limits on the walrus code, you are not reducing complexity, you > are increasing it. > You are increasing complexity because you can't just reuse the code that > handles an ordinary > assignment. You now need specific code to

Re: New assignmens ...

2021-10-25 Thread Antoon Pardon
Op 25/10/2021 om 18:06 schreef Avi Gross via Python-list: > Antoon, > > Just to be clear. I am talking about a different measure of efficiency. No you are not. > > The topic here is the Python run-time parser though. Yes and that is what I am talking about. > It is reading your code > and

Re: New assignmens ...

2021-10-25 Thread Chris Angelico
On Tue, Oct 26, 2021 at 3:07 AM Avi Gross via Python-list wrote: > I will end with this. If someone wants to design a new language from scratch > and with a goal of starting with as general a set of concepts as they can, > fine. Design it carefully. Build it and if it works well enough, use it.

Re: New assignmens ...

2021-10-25 Thread Christman, Roger Graydon
Message: 8 Date: Mon, 25 Oct 2021 11:20:52 +0200 From: Antoon Pardon To: python-list@python.org Subject: Re: New assignmens ... Message-ID: <5761dd65-4e87-8b8c-1400-edb821204...@vub.be> Content-Type: text/plain; charset=utf-8; format=flowed On 25/10/2021 11:20, Anton Pardon wrote: >

RE: New assignmens ...

2021-10-25 Thread Avi Gross via Python-list
e operation for the more complex scenarios even if they remember the fancy version exists and is bound to some forgotten series of keys clicked together like control-X control-alt-t or something. -Original Message- From: Python-list On Behalf Of Antoon Pardon Sent: Monday, October 25, 20

Re: New assignmens ...

2021-10-25 Thread Antoon Pardon
On 25/10/2021 01:46, Avi Gross via Python-list wrote: No, many things need not be as general as possible once you consider how much work it may take to develop code and how many bugs and oddities might be introduced and even how much it may slow the interpreter. ... I imagine you can create

RE: New assignmens ...

2021-10-24 Thread Avi Gross via Python-list
need to check your version of Python to see if the feature exists before ... -Original Message- From: Python-list On Behalf Of Alan Bawden Sent: Sunday, October 24, 2021 3:53 AM To: python-list@python.org Subject: Re: New assignmens ... It seemed weird to me that only an identifier

Re: New assignmens ...

2021-10-24 Thread Chris Angelico
On Mon, Oct 25, 2021 at 2:13 AM Alan Bawden wrote: > > It seemed weird to me that only an identifier was allowed to be the > target of an assignment expression. Then it occurred to me that > function definitions are another place where only identifiers are > allowed, but where I could imagine an

Re: New assignmens ...

2021-10-24 Thread O365 Dict
Op 23/10/2021 om 03:22 schreef Stefan Ram: > Paulo da Silva writes: >> Well, I didn't follow the discussion of this new feature, but the reason >> I can see behind allowing it seems so valid for for ctr:=ctr-1 as for >> self.ctr:=self.ctr-1. The kind of use is exactly the same. One is for a >>

Re: New assignmens ...

2021-10-24 Thread Alan Bawden
It seemed weird to me that only an identifier was allowed to be the target of an assignment expression. Then it occurred to me that function definitions are another place where only identifiers are allowed, but where I could imagine an attributeref or a subscription being used. E.g. def

Re: New assignmens ...

2021-10-23 Thread Chris Angelico
On Sun, Oct 24, 2021 at 7:48 AM Jon Ribbens via Python-list wrote: > > On 2021-10-23, Chris Angelico wrote: > > On Sun, Oct 24, 2021 at 4:39 AM Jon Ribbens via Python-list > > wrote: > >> On 2021-10-23, Chris Angelico wrote: > >> > In what situations do you need to mutate an attribute and also

Re: New assignmens ...

2021-10-23 Thread Ethan Furman
On 10/23/21 6:42 AM, Jon Ribbens via Python-list wrote: > On 2021-10-23, Chris Angelico wrote: >> The onus is on you to show that it needs to be more flexible. > > Is it though? Yes. > It seems to me that the onus is on you to show that > this special case is special enough to be given its own

Re: New assignmens ...

2021-10-23 Thread Jon Ribbens via Python-list
On 2021-10-23, Chris Angelico wrote: > On Sun, Oct 24, 2021 at 4:39 AM Jon Ribbens via Python-list > wrote: >> On 2021-10-23, Chris Angelico wrote: >> > In what situations do you need to mutate an attribute and also test >> > it, and how much hassle is it to simply break it out into two lines?

Re: New assignmens ...

2021-10-23 Thread Chris Angelico
On Sun, Oct 24, 2021 at 4:39 AM Jon Ribbens via Python-list wrote: > > On 2021-10-23, Chris Angelico wrote: > > I've never used ctr:=ctr-1 either, though, so I don't know the actual > > use cases. Why is this being used in an assignment expression? Is it > > an ersatz loop? > > > > Common

Re: New assignmens ...

2021-10-23 Thread Jon Ribbens via Python-list
On 2021-10-23, Chris Angelico wrote: > I've never used ctr:=ctr-1 either, though, so I don't know the actual > use cases. Why is this being used in an assignment expression? Is it > an ersatz loop? > > Common use-cases include: > > if m := re.match(...): > > while data := thing.read(): > > etc.

Re: New assignmens ...

2021-10-22 Thread dn via Python-list
On 23/10/2021 12.51, Greg Ewing wrote: > On 23/10/21 8:49 am, dn wrote: >> Whereas, creating a list (or tuple...) is legal because the structure's >> name is an "identifier"! > > No, the restriction only applies to the LHS. The list construction > is on the RHS. That contention (above) may have

Re: New assignmens ...

2021-10-22 Thread Chris Angelico
On Sat, Oct 23, 2021 at 12:24 PM Paulo da Silva wrote: > > Às 20:34 de 22/10/21, Chris Angelico escreveu: > > On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list > > wrote: > >> > >> On 2021-10-22, Stefan Ram wrote: > >>> Paulo da Silva writes: > Why doesn't this work >

Re: New assignmens ...

2021-10-22 Thread Paulo da Silva
Às 20:34 de 22/10/21, Chris Angelico escreveu: > On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list > wrote: >> >> On 2021-10-22, Stefan Ram wrote: >>> Paulo da Silva writes: Why doesn't this work if (self.ctr:=self.ctr-1)<=0: while this works if

Re: New assignmens ...

2021-10-22 Thread Greg Ewing
On 23/10/21 8:49 am, dn wrote: Whereas, creating a list (or tuple...) is legal because the structure's name is an "identifier"! No, the restriction only applies to the LHS. The list construction is on the RHS. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: New assignmens ...

2021-10-22 Thread dn via Python-list
With apologies for pressing Send too early... On 23/10/2021 08.41, dn via Python-list wrote: > On 23/10/2021 08.34, Chris Angelico wrote: >> On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list >> wrote: >>> >>> On 2021-10-22, Stefan Ram wrote: Paulo da Silva writes: > Why

Re: New assignmens ...

2021-10-22 Thread dn via Python-list
On 23/10/2021 08.34, Chris Angelico wrote: > On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list > wrote: >> >> On 2021-10-22, Stefan Ram wrote: >>> Paulo da Silva writes: Why doesn't this work if (self.ctr:=self.ctr-1)<=0: while this works if

Re: New assignmens ...

2021-10-22 Thread Chris Angelico
On Sat, Oct 23, 2021 at 6:24 AM Jon Ribbens via Python-list wrote: > > On 2021-10-22, Stefan Ram wrote: > > Paulo da Silva writes: > >>Why doesn't this work > >> if (self.ctr:=self.ctr-1)<=0: > >>while this works > >> if (ctr:=ctr-1)<=0: > > > > assignment_expression ::=

Re: New assignmens ...

2021-10-22 Thread Jon Ribbens via Python-list
On 2021-10-22, Stefan Ram wrote: > Paulo da Silva writes: >>Why doesn't this work >> if (self.ctr:=self.ctr-1)<=0: >>while this works >> if (ctr:=ctr-1)<=0: > > assignment_expression ::= [identifier ":="] expression, > but the attribute references "self.ctr" is no identifier!