[Python-ideas] Inline assignments using "given" clauses

Rhodri James rhodri at kynesim.co.uk
Mon May 14 07:05:18 EDT 2018

On 14/05/18 10:17, Greg Ewing wrote:
> Tim Peters wrote:
>> Because you never _need_ to use an assignment expression to write a
>> listcomp/genexp.
> This whole discussion started because someone wanted a way
> to bind a temporary result for use *within* a comprehension.

I still don't find that argument compelling.  If you have a sufficiently 
complicated comprehension that you need a temporary result bound, IMHO 
you are well on the way to (if not far past) the point where converting 
it into a more traditional for-loop will be much clearer.  I'm not sure 
we should be encouraging people to write less clear code.

Rhodri James *-* Kynesim Ltd

More information about the Python-ideas mailing list