Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-14 Thread Brice Parent
Le 10/05/2018 à 09:32, Terry Reedy a écrit : On 5/9/2018 11:33 PM, Guido van Rossum wrote: I now think that the best way out is to rule `:=` in the top level expression of an expression statement completely I would like to be able to interactively enter >>> a: = f(2,4) to have 'a' echoed

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-11 Thread Steven D'Aprano
On Thu, May 10, 2018 at 09:53:40AM -0400, Guido van Rossum wrote: [...] > So all in all I'm not sure I think this is important enough to support, and > the rule "Use `:=` in expressions, not as a top level assignment" seems > easier to explain and understand. Like Terry, I too would find it

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-11 Thread Tim Peters
[Guido] > ,,, > OT about the name: despite Tim's relentless pushing of "binding expressions" > in the end I think they should be called "assignment expressions" just like > in C. Ha! I already gave up on "binding expressions". For nearly a full day, I've been rigidly calling them "binding

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Greg Ewing
Tim Peters wrote: Umm ... that's the opposite of what the Reference Manual says "lower":means: """ 6.16. Operator precedence The following table summarizes the operator precedence in Python, from lowest precedence (least binding) to highest precedence (most binding). """ Which is also in

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Terry Reedy
On 5/10/2018 9:53 AM, Guido van Rossum wrote: On Thu, May 10, 2018 at 3:32 AM, Terry Reedy > wrote: On 5/9/2018 11:33 PM, Guido van Rossum wrote: I now think that the best way out is to rule `:=` in the top level expression of an

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Paul Moore
On 10 May 2018 at 17:38, Ethan Furman wrote: > On 05/10/2018 09:29 AM, M.-A. Lemburg wrote: >> >> On 10.05.2018 15:57, Guido van Rossum wrote: >>> >>> On Thu, May 10, 2018 at 5:04 AM, M.-A. Lemburg wrote: > > To a (former Pascal) programmer, a := 1 doesn't read like an

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Ethan Furman
On 05/10/2018 09:29 AM, M.-A. Lemburg wrote: On 10.05.2018 15:57, Guido van Rossum wrote: On Thu, May 10, 2018 at 5:04 AM, M.-A. Lemburg wrote: To a (former Pascal) programmer, a := 1 doesn't read like an operator. It's an assignment expression. If embedded expressions is where Python is

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread M.-A. Lemburg
On 10.05.2018 15:57, Guido van Rossum wrote: > On Thu, May 10, 2018 at 5:04 AM, M.-A. Lemburg wrote: > >> To a (former Pascal) programmer, a := 1 doesn't read like an >> operator. It's an assignment expression. If embedded expressions >> is where Python is heading, it should be

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Guido van Rossum
On Thu, May 10, 2018 at 5:04 AM, M.-A. Lemburg wrote: > To a (former Pascal) programmer, a := 1 doesn't read like an > operator. It's an assignment expression. If embedded expressions > is where Python is heading, it should be made very clear where > the embedded expression

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Guido van Rossum
On Thu, May 10, 2018 at 3:32 AM, Terry Reedy wrote: > On 5/9/2018 11:33 PM, Guido van Rossum wrote: > > I now think that the best way out is to rule `:=` in the top level >> expression of an expression statement completely >> > > I would like to be able to interactively enter >

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Nick Coghlan
On 10 May 2018 at 13:33, Guido van Rossum wrote: > (I vaguely recall this has been brought up before, but I'm too lazy to > find the subtread. So it goes.) > > PEP 572 currently seems to specify that when used in expressions, the > precedence of `:=` is lower (i.e. it binds

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread David Mertz
On Wed, May 9, 2018, 11:53 PM Guido van Rossum wrote: > Oh, I hadn't even though of combining the two in one statement. That > example is truly horrible (on first skim I didn't even notice it used two > different assignment operators!) and strengthens my confidence that we >

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Chris Angelico
On Thu, May 10, 2018 at 7:04 PM, M.-A. Lemburg wrote: > Not sure whether this was discussed before (I'm not really > following the discussion), but what happens if you write: > > check = 0 and (a := 1) > > ? Will "a" get assigned or not ? No, it won't. It's the same as any other

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread M.-A. Lemburg
On 10.05.2018 05:52, Guido van Rossum wrote: >> I would have := bind more tightly than the comma. Consider: >> >> a = 1, x := 2, 3 >> >> IMO the only sane interpretation is "x = 2; a = 1, 2, 3". Effectively, >> the := operator does not like to play with commas; we've already ruled >> out "a, b :=

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Terry Reedy
On 5/9/2018 11:33 PM, Guido van Rossum wrote: I now think that the best way out is to rule `:=` in the top level expression of an expression statement completely I would like to be able to interactively enter >>> a: = f(2,4) to have 'a' echoed as well as bound. -- Terry Jan Reedy

Re: [Python-ideas] PEP 572: about the operator precedence of := (Guido van Rossum)

2018-05-10 Thread Angus Hollands
sons I mentioned previously. Angus Hollands Message: 4 > Date: Wed, 9 May 2018 20:33:05 -0700 > From: Guido van Rossum <gu...@python.org> > To: Python-Ideas <python-ideas@python.org> > Subject: [Python-ideas] PEP 572: about the operator precedence of := > Message-ID: >

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Tim Peters
[Guido] > (I vaguely recall this has been brought up before, but I'm too lazy to find > the subtread. So it goes.) > > PEP 572 currently seems to specify that when used in expressions, the > precedence of `:=` is lower (i.e. it binds more tightly) Umm ... that's the opposite of what the Reference

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Guido van Rossum
On Wed, May 9, 2018 at 8:42 PM, Chris Angelico wrote: > On Thu, May 10, 2018 at 1:33 PM, Guido van Rossum > wrote: > > (I vaguely recall this has been brought up before, but I'm too lazy to > find > > the subtread. So it goes.) > > > > PEP 572 currently seems

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Chris Angelico
On Thu, May 10, 2018 at 1:33 PM, Guido van Rossum wrote: > (I vaguely recall this has been brought up before, but I'm too lazy to find > the subtread. So it goes.) > > PEP 572 currently seems to specify that when used in expressions, the > precedence of `:=` is lower (i.e. it

[Python-ideas] PEP 572: about the operator precedence of :=

2018-05-09 Thread Guido van Rossum
(I vaguely recall this has been brought up before, but I'm too lazy to find the subtread. So it goes.) PEP 572 currently seems to specify that when used in expressions, the precedence of `:=` is lower (i.e. it binds more tightly) than all operators except for the comma. I derive this from the