<p>Sometimes I find myself in the situation where I want to execute several sequential commands like such:</p>

<pre><code>try:
    foo(a, b)
except Exception, e:
    baz(e)
try:
    bar(c, d)
except Exception, e:
    baz(e)
...
</code></pre>

<p>This same pattern occurs when exceptions simply need to be ignored.</p>

<p>This feels redundant and the excessive syntax causes it to be surprisingly difficult to follow when reading code.</p>

<p>In C, I would have solved this type of problem easily with a macro, but unfortunately, this cannot be done in straight python.</p>

<p>Question: How can I best reduce the code footprint and increase code readability when coming across this pattern?</p>

If they're simple one-line commands, you can wrap them in
```
lambda
```
s:
```
```
for cmd in [
    (lambda: foo (a, b)),
    (lambda: bar (c, d)),
]:
    try:
        cmd ()
    except StandardError, e:
        baz (e)
```
```
You could wrap that whole thing up in a function, so it looked like this:
```
```
ignore_errors (baz, [
    (lambda: foo (a, b)),
    (lambda: bar (c, d)),
])
```
```