Python's answer to blocks tends to be the with statement, so your example would look like<p><pre><code>  with task('name') as t:
    # do stuff with t
</code></pre>
It's not really the same; the task object doesn't have control over whether the block is actually run, but sometimes it is sufficient.