19 May
2018
19 May
'18
11:42 a.m.
Paul Svensson wrote:
I don't quite get what's so subtle about it, am I missing something?
The "with" keyword calls "__enter__", and "as" gives it a name.
Just like "-x + y" is different from "-(x + y)",
I think the difference is that mentally one already tends to think of "with x as y" being grouped "with (x as y)" rather than "(with x) as y". So, if "x as y" becomes a legal expression all by itself, it will *seem* as though the meaning of "as" is changed simply by adding explicit parentheses around an expression that was already implicitly parenthesised. Whether this is too subtle or not is a matter of opinion, but it was raised as one of the objections to using "as", so some people obviously thought so. -- Greg