[Python-ideas] Reuse "for" to express "given"

Rob Cliffe rob.cliffe at btinternet.com
Fri May 25 10:06:25 EDT 2018



On 24/05/2018 16:54, Alexander Belopolsky wrote:
> I have read most of the PEP 572 related threads, but I don't think 
> I've seen this idea.  As many other people mentioned, Python already 
> allows a trick to introduce local bindings in generator expressions 
> and list comprehensions.  This can be achieved by adding a "for var in 
> [<expr>]" clause. I propose to make "for var = <expr>" have the same 
> effect as "for var in [<expr>]".
>
>
I made this exact same suggestion some time ago (not in the context of 
PEP 572).  Guido rejected it because it is easy (especially for newbies) 
to confuse
     for var in expr
     for var = expr
I point out that the confusion is particularly acute in the cases such as
     for x = SomeTuple
Rob Cliffe


More information about the Python-ideas mailing list