[Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

Chris Angelico rosuav at gmail.com
Fri Apr 13 17:44:35 EDT 2018


On Sat, Apr 14, 2018 at 7:33 AM, Kirill Balunov <kirillbalunov at gmail.com> wrote:
>
>
> 2018-04-13 23:31 GMT+03:00 Chris Angelico <rosuav at gmail.com>:
>>
>>
>> >     # but these are subtly different and will be a trap for the unwary
>> >     with expression as name:  # name is set to __enter__()
>> >     with (expression as name):  # name is not set to __enter__()
>>
>> And that's a good reason to reject the last one with a SyntaxError,
>> but that creates an odd discrepancy where something that makes perfect
>> logical sense is rejected.
>>
>
> Maybe it does not suit you, but what do you think about `SyntaxWarning`
> instead of `SyntaxError` for both `with` and `except`. By analogy how it was
> done for `global name` into function body prior to Python 3.6?

Warnings are often not seen. For an error this subtle, a warning
wouldn't be enough.

Good call though; that was one of the considerations, and if we knew
for sure that warnings could be seen by the right people, they could
be more useful for these cases.

ChrisA


More information about the Python-ideas mailing list