Why aren't OrderedDicts comparable with < etc?
Sion Arrowsmith
sion at viridian.paintbox
Fri Jul 17 06:20:34 EDT 2009
Jack Diederich <jackdied at gmail.com> wrote:
>It isn't an OrderedDict thing, it is a comparison thing. Two regular
>dicts also raise an error if you try to LT them.
Since when?
Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d1 = dict((str(i), i) for i in range (10))
>>> d2 = dict((str(i), i) for i in range (20))
>>> d1 < d2
True
>>>
(Don't have a 2.6 or 3 to hand.)
Mind you, it makes even less sense for a regular dict than an
OrderedDict. And it's not like d1.items() < d2.items() is a
huge burden, if that's what you want dictionary comparison to
mean.
--
\S
under construction
More information about the Python-list
mailing list