[Python-Dev] The `for y in [x]` idiom in comprehensions

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Feb 27 13:41:19 EST 2018


On Mon, Feb 26, 2018 at 7:51 PM, Guido van Rossum <guido at python.org> wrote:
..
> The reason is that for people who are not Python experts there's no obvious
> reason why `for VAR = EXPR` should mean one thing and `for VAR in EXPR`
> should mean another.

This would be particularly surprising for people exposed to Julia
where these two forms are equivalent:

julia> for x = [1,2] println(x); end
1
2

julia> for x in [1,2] println(x); end
1
2


More information about the Python-Dev mailing list