[Python-Dev] Re: other "magic strings" issues
Martin v. Löwis
martin at v.loewis.de
Wed Nov 12 15:31:42 EST 2003
David Eppstein <eppstein at ics.uci.edu> writes:
> Let me be more specific. Since we have such useful hashing-based
> dictionary data structures in Python, we don't often need cmp for
> binary search trees, so the main reason for comparing unicodes (as far
> as I can tell) is to put them in a logical order for displaying to
> humans. cmp(unicode,unicode) does a very bad job of this, whenever
> there are non-ascii characters involved. Its existence tricks you into
> thinking Python has a useful unicode comparison function when it
> doesn't.
It's useful for sorting, but not for collation. Comparing!=Collating.
That said, locale.strcoll does what you want.
Regards,
Martin
More information about the Python-Dev
mailing list