On Thu, 26 Apr 2018 08:38:51 +1000 Chris Angelico firstname.lastname@example.org wrote:
On Thu, Apr 26, 2018 at 8:08 AM, Antoine Pitrou email@example.com wrote:
On Wed, 25 Apr 2018 16:55:43 -0500
Tim Peters firstname.lastname@example.org 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.