A generator expression is a compact generator notation in parentheses:
generator_expression | ::= | "(" test genexpr_for ")" |
genexpr_for | ::= | "for" expression_list "in" test [genexpr_iter] |
genexpr_iter | ::= | genexpr_for | genexpr_if |
genexpr_if | ::= | "if" test [genexpr_iter] |
A generator expression yields a new generator object. The iterating values would be produced by considering each of the for or if clauses a block, nesting from left to right, and evaluating the expression to yield a value that is reached the innermost block for each iteration.
innermost
adj
1: being deepest within the self;
2: situated or occurring farthest within;
沒有留言:
張貼留言