[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-07 Thread Chris Angelico
On Mon, Feb 8, 2021 at 4:21 PM Random832 wrote: > > > On Sat, Feb 6, 2021 at 5:21 PM Random832 wrote: > > > > > > While we're on the subject of assignment expression limitations, I've > > > occasionally wanted to write something like > > > > > > try: > > > return a_dict[key] > > > except

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-07 Thread Random832
> On Sat, Feb 6, 2021 at 5:21 PM Random832 wrote: > > > > While we're on the subject of assignment expression limitations, I've > > occasionally wanted to write something like > > > > try: > > return a_dict[key] > > except KeyError: > > return (a_dict[key] := expression to construct

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-06 Thread Chris Angelico
On Sat, Feb 6, 2021 at 8:54 PM Paul Sokolovsky wrote: > > Hello, > > On Sat, 6 Feb 2021 17:26:00 +1100 > Chris Angelico wrote: > > > On Sat, Feb 6, 2021 at 5:21 PM Random832 > > wrote: > > > > > > While we're on the subject of assignment expression limitations, > > > I've occasionally wanted to

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-06 Thread Paul Sokolovsky
Hello, On Sat, 6 Feb 2021 17:26:00 +1100 Chris Angelico wrote: > On Sat, Feb 6, 2021 at 5:21 PM Random832 > wrote: > > > > While we're on the subject of assignment expression limitations, > > I've occasionally wanted to write something like > > > > try: > > return a_dict[key] > > except

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-06 Thread Paul Sokolovsky
Hello, On Sat, 6 Feb 2021 10:46:54 +0200 Serhiy Storchaka wrote: > 05.02.21 09:51, Paul Sokolovsky пише: > > a0 = 0 > > b0 = 10 > > while ((a1, b1) := phi([a0, a2], [b0, b2]))[0] < 5: > > a2 = a1 + 1 > > b2 = b1 + 1 > > Such code quickly becomes unreadable. Especially if in real code

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-06 Thread Paul Sokolovsky
Hello, On Sat, 6 Feb 2021 06:17:08 +1100 Chris Angelico wrote: > On Sat, Feb 6, 2021 at 6:08 AM Paul Sokolovsky > wrote: > > And looking back now, that seems like intentionally added accidental > > gap in the language (https://en.wikipedia.org/wiki/Accidental_gap). > > Similar to artificially

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Brendan Barnwell
On 2021-02-05 22:18, Random832 wrote: While we're on the subject of assignment expression limitations, I've occasionally wanted to write something like try: return a_dict[key] except KeyError: return (a_dict[key] := expression to construct value) You can already do that with

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Chris Angelico
On Sat, Feb 6, 2021 at 5:21 PM Random832 wrote: > > While we're on the subject of assignment expression limitations, I've > occasionally wanted to write something like > > try: > return a_dict[key] > except KeyError: > return (a_dict[key] := expression to construct value) That's what

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Random832
While we're on the subject of assignment expression limitations, I've occasionally wanted to write something like try: return a_dict[key] except KeyError: return (a_dict[key] := expression to construct value) ___ Python-ideas mailing list --

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Chris Angelico
On Sat, Feb 6, 2021 at 6:08 AM Paul Sokolovsky wrote: > And looking back now, that seems like intentionally added accidental > gap in the language (https://en.wikipedia.org/wiki/Accidental_gap). > Similar to artificially limiting decorator syntax, which was already > un-limited. But seems,

[Python-ideas] Re: [Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Paul Sokolovsky
Hello, Thanks for the reply. On Fri, 5 Feb 2021 13:32:25 -0500 Terry Reedy wrote: > On 2/5/2021 2:51 AM, Paul Sokolovsky wrote: > > > https://www.python.org/dev/peps/pep-0572/ > ... > > ((a, b) := (1, 2)) > >File "", line 1 > > SyntaxError: cannot use assignment expressions