[Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
Antoine Pitrou
solipsis at pitrou.net
Wed Apr 25 18:44:48 EDT 2018
More information about the Python-Dev mailing list
Wed Apr 25 18:44:48 EDT 2018
- Previous message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Next message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 26 Apr 2018 08:38:51 +1000 Chris Angelico <rosuav at gmail.com> wrote: > On Thu, Apr 26, 2018 at 8:08 AM, Antoine Pitrou <solipsis at pitrou.net> wrote: > > On Wed, 25 Apr 2018 16:55:43 -0500 > > Tim Peters <tim.peters at gmail.com> wrote: > >> > >> To my eyes, this is genuinely harder to follow, despite its relative brevity: > >> > >> while total != (total := total + term): > > > > Does it even work? Perhaps if the goal is to stop when total is NaN, > > but otherwise? > > Yes, it does, because the first "total" is looked up before the > rebinding happens. It's 100% unambiguous to the compiler... but still > pretty unclear to a human. And I think the multiple use of 'total' is > to blame for that. So I agree with Tim that this particular example is > better in longhand. "Better" is an understatement :-( Now that I understood it (thanks for the explanation), the shorthand version appears completely bonkers. Regards Antoine.
- Previous message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Next message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list