Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

88888 Dihedral dihedral88888 at gmail.com
Tue Mar 25 06:17:11 EDT 2014


> >>> x = [[1, 2], [3, 4]]
> 
> >>> for x in x:
> 
> ...     for x in x:
> 
> ...         print(x)
> 
This is valid in the syntax level 
in python. But it is only good
for those  writing obscure programs in 
my opinions at most team works. 



More information about the Python-list mailing list