2 ms·
The behavior is built into the "with" statement. It does not do a direct assignment, but assigns to the result of the context manager call. So having two ways
by mixmastamyk 8y ago
The behavior is built into the "with" statement. It does not do a direct assignment, but assigns to the result of the context manager call. So having two ways to use "as" in the same statement, with different rules, and confusion of which is which is a mess. Except and import have the issue also with different rules.
On the other hand additional "as" assignments are not very useful under those statements, so it would not really happen for the most part.
A good compromise discussed was to restrict the "as" assignments to the "if" and "while" statements, and perhaps comprehensions, the only areas there were actual use cases.
The PEP authors didn't like this compromise, even though many new languages are choosing this design. They pushed ahead despite resistance from all angles.
In short, controversial PEPs that reverse twenty-five year old design choices are controversial. Not sure what they were expecting.