beginner, idiomatic python

Alex Martelli aleax at mac.com
Mon Aug 27 00:05:17 EDT 2007


bambam <david at asdf.asdf> wrote:

> Is it safe to write
> 
> A = [x for x in A if x in U]
> 
> or is that undefined? I understand that the slice operation

It's perfectly safe and well-defined, as the assignment rebinds the LHS
name only AFTER the RHS list comprehension is done.


Alex



More information about the Python-list mailing list