Re: [Tutor] Syntax for list comps

2016-02-03 Thread Ben Finney
Johan Martinez writes: > Where can I find syntax for list comps? The same place as other syntax descriptions: in the language reference https://docs.python.org/3/reference/expressions.html#displays-for-lists-sets-and-dictionaries>. > I am confused how/whether they are evaluated left-right or ri

Re: [Tutor] Syntax for list comps

2016-02-03 Thread Danny Yoo
On Wed, Feb 3, 2016 at 8:52 PM, Johan Martinez wrote: > Where can I find syntax for list comps? I am confused how/whether they are > evaluated left-right or right-left. Consider following list flattening > example: > > mx = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] > > [value for row in mx for value in ro

[Tutor] Syntax for list comps

2016-02-03 Thread Johan Martinez
Where can I find syntax for list comps? I am confused how/whether they are evaluated left-right or right-left. Consider following list flattening example: mx = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [value for row in mx for value in row] [1, 2, 3, 4, 5, 6, 7, 8, 9] It seems like 'for' loops are eval