[Python-checkins] r67869 - python/branches/py3k-issue1717/Tools/unicode/makeunicodedata.py
M.-A. Lemburg
mal at egenix.com
Sat Dec 20 13:34:25 CET 2008
On 2008-12-20 11:28, mark.dickinson wrote:
> Author: mark.dickinson
> Date: Sat Dec 20 11:28:00 2008
> New Revision: 67869
>
> Log:
> Replace use of cmp in Tools/unicode/makeunicodedata.py
Wouldn't it be better to replace the cmpwords() function itself
with a key function ?
> Modified:
> python/branches/py3k-issue1717/Tools/unicode/makeunicodedata.py
>
> Modified: python/branches/py3k-issue1717/Tools/unicode/makeunicodedata.py
> ==============================================================================
> --- python/branches/py3k-issue1717/Tools/unicode/makeunicodedata.py (original)
> +++ python/branches/py3k-issue1717/Tools/unicode/makeunicodedata.py Sat Dec 20 11:28:00 2008
> @@ -511,10 +511,18 @@
> def cmpwords(a,b):
> aword, alist = a
> bword, blist = b
> - r = -cmp(len(alist),len(blist))
> - if r:
> - return r
> - return cmp(aword, bword)
> + len_alist, len_blist = len(alist), len(blist)
> + if len_alist != len_blist:
> + if len_alist < len_blist:
> + return 1
> + else:
> + return -1
> + if aword != bword:
> + if aword < bword:
> + return -1
> + else:
> + return 1
> + return 0
> wordlist.sort(key=CmpToKey(cmpwords))
>
> # figure out how many phrasebook escapes we need
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Dec 20 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2008-12-02: Released mxODBC.Connect 1.0.0 http://python.egenix.com/
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-checkins
mailing list