Python's answer to blocks tends to be the with statement, so your example would look like
with task('name') as t:
# do stuff with t
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.