[Python-Dev] PEP 572 and assert
Guido van Rossum
guido at python.org
Tue Jul 17 11:48:46 EDT 2018
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...
More information about the Python-Dev