28 Apr
2018
28 Apr
'18
8:04 p.m.
On 2018-04-28 18:36, Chris Angelico wrote:
This makes reasonable sense. The parentheses completely enclose the local scope. It's compiler magic, and you cannot explain it as a function call, but it makes intuitive sense. But the same thing inside the if header itself would be much weirder. I'm actually not even sure what it would do. And you've clearly shown that the local() call can be anywhere inside the condition, based on these examples:
What if the names persist until the end of the statement? That covers if (where the statement lasts until the end of the if...elif...else block) and regular expressions, though it does introduce a potentially annoying shadowing thing:
x = 2 (local(x=4, x + 1), x) (5,4)