Clarify when the iter() is called.
This commit is contained in:
parent
18428862ff
commit
b8c832a6fa
|
@ -102,7 +102,7 @@ semantic and syntactic specification.)
|
|||
def __gen(exp):
|
||||
for x in exp:
|
||||
yield x**2
|
||||
g = __gen(range(10))
|
||||
g = __gen(iter(range(10)))
|
||||
print g.next()
|
||||
|
||||
Only the outermost for-expression is evaluated immediately, the other
|
||||
|
@ -119,7 +119,7 @@ semantic and syntactic specification.)
|
|||
for var2 in exp3:
|
||||
if exp4:
|
||||
yield tgtexp
|
||||
g = __generator(exp1)
|
||||
g = __gen(iter(exp1))
|
||||
del __gen
|
||||
|
||||
2. The syntax requires that a generator expression always needs to be
|
||||
|
|
Loading…
Reference in New Issue