Python3 defines for loop as for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] in the grammar book. suite is defined as suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT.
For me, it's hard to understand how double for loop fits in the grammar description for list comprehension.
There are several smaller questions:
- And what about
else? I assume it's used for list comprehension. - Then does a normal for loop can use
elseblock?
I'd appreciate if you can come with examples.