diff Tools/unicode/makeunicodedata.py @ 51122:adbd77a90bde 3.0

Merged revisions 69025 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r69025 | mark.dickinson | 2009-01-27 18:17:45 +0000 (Tue, 27 Jan 2009) | 3 lines Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from the standard library and tests. ........
author Mark Dickinson <dickinsm@gmail.com>
date Tue, 27 Jan 2009 18:31:30 +0000
parents dc60293b29d5
children ca02bd8c96f2
line wrap: on
line diff
--- a/Tools/unicode/makeunicodedata.py	Tue Jan 27 11:04:59 2009 +0000
+++ b/Tools/unicode/makeunicodedata.py	Tue Jan 27 18:31:30 2009 +0000
@@ -457,15 +457,6 @@
 # --------------------------------------------------------------------
 # unicode name database
 
-def CmpToKey(mycmp):
-    'Convert a cmp= function into a key= function'
-    class K(object):
-        def __init__(self, obj, *args):
-            self.obj = obj
-        def __lt__(self, other):
-            return mycmp(self.obj, other.obj) == -1
-    return K
-
 def makeunicodename(unicode, trace):
 
     FILE = "Modules/unicodename_db.h"
@@ -508,14 +499,10 @@
     wordlist = list(words.items())
 
     # sort on falling frequency, then by name
-    def cmpwords(a,b):
+    def word_key(a):
         aword, alist = a
-        bword, blist = b
-        r = -cmp(len(alist),len(blist))
-        if r:
-            return r
-        return cmp(aword, bword)
-    wordlist.sort(key=CmpToKey(cmpwords))
+        return -len(alist), aword
+    wordlist.sort(key=word_key)
 
     # figure out how many phrasebook escapes we need
     escapes = 0