title: keyerror in python table
body: <p>I'm confused about the code below:</p>
  
  <pre><code>class Table(object):
      def __init__(self):
          self.d = collections.defaultdict(dict)
      def add(self, row, col, val):
          self.d[row][col] = val
      def get(self, row, col, default=None):
          return self.d[row].get(col, default)
      def incol(self, col, val):
          for x,y in self.d.iteritems():
              if y[col]==val:
                  wholerow=y
          return wholerow.values()
  </code></pre>
  
  <p>After I created table, I cannot use the "incol" function to get all the values. It always give me key error. However, when I just use the same code without using function, I can get what I want. What happened to my code....</p>