On Wed, Jul 18, 2018 at 2:24 AM, Serhiy Storchaka <storch...@gmail.com> wrote:
> 17.07.18 18:48, Guido van Rossum пише:
>>
>> On Tue, Jul 17, 2018 at 8:28 AM, Serhiy Storchaka <storch...@gmail.com
>> <mailto:storch...@gmail.com>> wrote:
>>     Should not the assert statement introduce an implicit lexical scope
>>     for preventing leaking variables?
>>
>> I don't see why. As Chris said, side effects in asserts are nothing new
>> and this PEP is not the one to do something about it.
>
>
> This side effect is new. No other expressions that can be used in asserts
> leaked local variables before. The only exception is list comprehensions in
> Python 2, and this was fixed in Python 3.

There are plenty of expressions that have side effects, though.
Creating local variables is just one type of side effect. If
assertions are being misused, that is the fault of people writing bad
assertions, not of assignment expressions, dict.setdefault(),
subprocess.call(), or any other operation.

Point of interest: You're basically asking for statement-local
assignment, which was one of PEP 572's earliest forms. It received
even more backlash than the current version did. The wheel turns and
the same spoke comes up...

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to