Message-ID: <2121080197.2791.1369319120194.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_2790_985129560.1369319120194" ------=_Part_2790_985129560.1369319120194 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Note: If you are not familiar with the generator concept, this <= a href=3D"/display/BOO/Generator+Breakdown">Generator Breakdown page sh= ould be read before continuning.
Generator expressions are defined through the pattern:
Generator expressions can be used as return values:
Generator expressions can be stored in variables:
Generator expressions can be used as arguments to functions:
In all cases the evaluation of each inner expression happens only
Generator expressions capture their enclosing environment (like closures= do) and thus are able to affect it by updating variables:
As well as being affected by changes to captured variables:
boo's variable capturing behavior differs in behavior from python's in a= subtle but I think good way:
This program properly prints the sins followed by the cosines of 0, 1, 2= because for controlled variable references (such as f) in= boo generator expressions as well as in closures are bound early= strong>.
If you don't know what the python behavior would be check this document.------=_Part_2790_985129560.1369319120194--