New Ordered Dictionery to Criticise

"Martin v. Löwis" martin at v.loewis.de
Mon Nov 28 21:13:20 CET 2005


Fuzzyman wrote:
> Criticism solicited (honestly) :-)

A couple of minor points:
- I would drop 2.2 compatibility
- self=self isn't needed in the functions, because of
   nested scopes
- popitem(self) can be rewritten as

   def popitem(self):
       try:
           key = self._sequence.pop()
       except IndexError:
           # always try to give the same exception string as
           # dict
           raise KeyError("popitem(): dictionary is empty")
       return key, self.pop(key)

- One problem with the FancyDict is that it allows
   d.keys.append(100)

Regards,
Martin




More information about the Python-list mailing list