David A. Wheeler wrote:
> Bill Janssen:
>> I'm a bit baffled here; I find cmp() fairly handy in writing sort routines...
>> Is there a better / newer / official way of doing this? If not, isn't
>> "cmp()" still useful to have around?
> 
> I agree with you - I find cmp() useful, and I notice that some others do too.
> E.G., Adam Olson said "It's clear to me that the opposition to
> removing __cmp__ comes down to "make the common things easy and
> the rare things possible".  Removing __cmp__ means one of the
> common things (total ordering) becomes hard."

I like cmp, too. I've looked through my code, and I've only used it in 
script-ish circumstances, but here is an example that sorts a list of 
files by modification date:

def cmp_mtime(f, g):
     """Too much for a lambda for my tastes."""
     return cmp(os.stat(f).st_mtime, os.stat(g).st_mtime)

files = os.listdir('.')
files.sort(cmp_mtime)

- Lars
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to