On Wed, 18 Apr 2007 01:45:10 -0700, Paul McGuire wrote: >> For the record, this is what I actually wanted: a four-line self-sorting >> dictionary: >> >> class SortedDict(dict): >> def __iter__(self): >> for key in sorted(self.keys()): >> yield key
[snip] > Very neat. Why not this? > > class SortedDict(dict): > def __iter__(self): > return iter(sorted(self.keys())) Good question. I don't have a good answer except for "because I didn't think of it". -- Steven. -- http://mail.python.org/mailman/listinfo/python-list