Comparisons of incompatible types

Ben Finney ben+python at benfinney.id.au
Tue Dec 7 20:11:33 EST 2010


Paul Rubin <no.email at nospam.invalid> writes:

> Ben Finney <ben+python at benfinney.id.au> writes:
> > but, if there is no ‘set’ type, it's fine to write::
> >     sorted(foolist) == sorted(barlist)
>
> what about dictionaries?

Creating a needless dict for each list would make the code even less
clear, I'd think. (We're talking here about design, which is why clarity
of communicating semantic intent is a concern.)

Of course, the ‘set’ type is an even clearer way of communicating the
intent; so, the above doesn't need to work in Python 3, which can break
code written before the advent of the ‘set’ type.

-- 
 \       “But Marge, what if we chose the wrong religion? Each week we |
  `\          just make God madder and madder.” —Homer, _The Simpsons_ |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list