Python isn't catching KeyError properly
<p>I've tried two different versions of the same function:</p>

<pre><code>def position_of(self, table_name, column_name):
    positions = self.heading_positions()
    position = positions['{t}.{c}'.format(t=table_name, c=column_name)]
    return position
</code></pre>

<p>-</p>

<pre><code>def position_of(self, table_name, column_name):
    positions = self.heading_positions()
    try:
        position = positions['{t}.{c}'.format(t=table_name, c=column_name)]
    except KeyError:
        raise RuntimeError('No heading found for {t}.{c} in import profile "{ip}"'.format(t=table_name, c=column_name, ip=self))
    return position
</code></pre>

<p>With the first version, I get the following error, which is fine:</p>

<pre><code>Traceback (most recent call last):
  File "./import.py", line 15, in &lt;module&gt;
    g.process()
  File "/home/jason/projects/mcifdjango/mcif/models/generic_import.py", line 39, in process
    row.process()
  File "/home/jason/projects/mcifdjango/mcif/models/csv_row.py", line 18, in process
    self.save()
  File "/home/jason/projects/mcifdjango/mcif/models/csv_row.py", line 26, in save
    self.output("Phone: " + self.value('customer', 'phone'));
  File "/home/jason/projects/mcifdjango/mcif/models/csv_row.py", line 60, in value
    print self.generic_import.import_profile.position_of(table_name, column_name)
  File "/home/jason/projects/mcifdjango/mcif/models/import_profile.py", line 22, in position_of
    position = positions['{t}.{c}'.format(t=table_name, c=column_name)]
KeyError: 'customer.phone'
</code></pre>

<p>But the second version - the one that has the more informative error description - fails silently. Why is this?</p>
