News for hackers. Stuff that matters.
Re:Why is Python more fun than Java? by d0mine on Tuesday July 29, 2008 @11:24AM (#260592)
Additionaly,

  def increment(key):
      with lock(self.lock):
          value = self.counter_table.get(key)
          if not value:
              self.counter_table.add(key, 1)
              value = 1
Should be replace by:

  def increment(self, key):
      with lock(self.lock):
          value = self.counter_table[key] = self.counter_table.setdefault(key, 0) + 1
      return value
UserDict.DictMixin has setdefault method, therefore it is reasonable to assume that a dictionary-like object should have it.

There are no comments on this comment yet.