Generator (computer programming): Difference between revisions

Content deleted Content added
Undid revision 422362912 by 117.211.90.122 (talk) - Undoing change. Icon's facility is specifically called "Goal Directed Evaluation"
Martnym (talk | contribs)
m Generator Expressions: Fixed misspelled word in description and changed a constant in the example code so it makes sense.
Line 82:
 
====Generator Expressions====
Python has a syntax modelledmodeled on that of [[list comprehension]]s, called a generator expression that aids in the creation of generators.
The following extends the example above by using a generator expression to compute squares from the countfrom generator function:
<source lang="python">
squares = ( n*n for n in countfrom(010) )
 
for j in squares: