Clarify when the iter() is called.

This commit is contained in:
Raymond Hettinger 2004-05-20 22:57:01 +00:00
parent 18428862ff
commit b8c832a6fa
1 changed files with 2 additions and 2 deletions

View File

@ -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