[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] PEP 572 and assert

On Tue, Jul 17, 2018 at 8:28 AM, Serhiy Storchaka <storchaka at gmail.com>

> 17.07.18 17:59, Guido van Rossum ????:
>> The PEP has no specific opinion except it is not forbidden.
>> Personally I like Barry's example just fine -- assuming `subdirs` is not
>> used later, this feels like a good use case.
> Shouldn't this problem be solved in the same way as for comprehensions?

No, it's nothing like those.

> 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.

Serhiy, have you even read the latest version of PEP 572? In its current
form it does not introduce any implicit scopes and even goes out of its way
to make assignments in comprehensions "leak" out of the comprehension scope
into the surrounding (explicit, using 'def' or 'lambda') function's scope.

--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180717/317b35ef/attachment.html>