[Python-ideas] A PEP on introducing variables on 'if' and 'while'

Steven D'Aprano steve at pearwood.info
Sat Jun 9 08:57:21 EDT 2018


On Sat, Jun 09, 2018 at 08:43:47AM -0400, Juancarlo Añez wrote:
> Hello @here,
> 
> Is there a guide about writing (and publishing) PEPs?

https://www.python.org/dev/peps/pep-0001/
 
> I'd like to write one on `while expre as v: ...` using the context
> semantics of `with expr as v` (not `except E as e`).

Do you mean the context manager semantics of with statements? As in, 
calling the __enter__ and __exit__ method?

Please make sure you are very familiar with PEP 572 before you do, and 
expect to have your PEP compared to it.

Be especially prepared to be challenged with the question what is so 
special about while and if that they, and they alone, are permitted to 
use assignment expressions. (You don't have to answer that now provided 
it is answered in the PEP.)


-- 
Steve


More information about the Python-ideas mailing list