| 264 | | So, we've replaced the <q>order of lines is order of execution</q> with a |
| 265 | | deliberate, in-Python encoding of the order of execution, |
| 266 | | where <code class="python">d</code> represents the particular flow and |
| 267 | | <code class="python">d.addCallback</code> replaces <q>new line</q>. |
| | 264 | So, we've replaced the <q>order of lines is order of execution</q> model with a |
| | 265 | deliberate, in-Python encoding of the order of execution. |
| | 266 | The control-flow is represented by <code class="python">d</code>, |
| | 267 | and <code class="python">d.addCallback</code> declares your <q>next actions</q>. |
| 278 | | In what follows, we are going to take each way of expressing order of |
| 279 | | operations in Python using sequences of lines |
| 280 | | and <code class="python">try</code>/<code class="python">except</code> and |
| 281 | | translate them into an equivalent built with <code class="API" |
| 282 | | base="twisted.internet.defer">Deferred</code>. |
| | 277 | In what follows, we are going to take each different way of expressing |
| | 278 | order of operations in normal Python (with code lines and |
| | 279 | <code class="python">try</code>/<code class="python">except</code>) and |
| | 280 | translate them into an equivalent code built with <code class="API" |
| | 281 | base="twisted.internet.defer">Deferred</code> objects. |
| 286 | | This is going to be a bit painstaking, but if you want to really understand |
| 287 | | how to use <code class="API" base="twisted.internet.defer">Deferred</code>s |
| 288 | | and how to understand and maintain code that uses <code class="API" |
| 289 | | base="twisted.internet.defer">Deferred</code>s, it is worth understanding |
| 290 | | each of these examples. |
| | 285 | This is going to be a bit painstaking, but if you really want to understand |
| | 286 | how to use <code class="API" base="twisted.internet.defer">Deferred</code>s, |
| | 287 | and maintain code that uses them, then it's worth understanding each example |
| | 288 | below. |