Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80480
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.044 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'works.': 0.09; 'posted': 0.15; 'cmp': 0.16; 'tried:': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'case.': 0.24; 'simpler': 0.24; 'mon,': 0.24; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'received:google.com': 0.35; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'subject:" ': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'otten': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=lWhFG+88uVJ5jx7GRvRAC9nGmYRrsYu5Ut28up2328U=; b=seCEvI2OuRrPz8+oUVVKcCk0pthISBOgc4RJLO3p4GY9/mxko2tMXYhR91dSm0KheZ C6X5jNG//27jilr5iRF9FsIJIBjBzwkZr6sMdFIbC2kj/uh0HIoTKtQbraep9Kmpjqjn mifGZB0X27BIfADbM4AFF6xQs4ursoHlm5oVtuY2F1dcaLB70AO8ztmSro4xM5K/oKpu PMhtcsUaCULiThMaiiP01hdn77O/Q3mNp90HSDFeTcjhEdKXN3yVoIutToIQ447ERPMv ZB3pe+CBbZPRy+P50pY2g36dMrNpUqHB+SSeDuabhqAczMRjIMr+3DnnIYQp7kWXlslz aeQg== |
| X-Received | by 10.68.111.161 with SMTP id ij1mr34757887pbb.10.1415648660024; Mon, 10 Nov 2014 11:44:20 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <m3r34j$hb7$1@ger.gmane.org> |
| References | <eb697764-934b-4650-af28-1c55520bc1da@googlegroups.com> <m3r34j$hb7$1@ger.gmane.org> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 10 Nov 2014 12:43:39 -0700 |
| Subject | Re: "Natural" use of cmp= in sort |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15631.1415648663.18130.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1415648663 news.xs4all.nl 2883 [2001:888:2000:d::a6]:59197 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:80480 |
Show key headers only | View raw
On Mon, Nov 10, 2014 at 12:19 PM, Peter Otten <__peter__@web.de> wrote:
> I'm not sure this works. I tried:
Here's a simpler failure case.
>>> ineq = """f2 > f3
... f3 > f1"""
[Previously posted code elided]
>>> greater_thans
set([('f3', 'f1'), ('f2', 'f3')])
>>> sorted(all_f, cmp=lambda t1, t2: 0 if t1==t2 else
... (1 if (t1, t2) not in greater_thans else -1))
['f1', 'f2', 'f3']
Note that the greater_thans set is missing the implication by
transitivity that f2 > f1, so the given cmp function would
inconsistently return -1 for both comparisons cmp('f1', 'f2') and
cmp('f2', 'f1').
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
"Natural" use of cmp= in sort Paddy <paddy3118@gmail.com> - 2014-11-10 10:45 -0800
Re: "Natural" use of cmp= in sort Peter Otten <__peter__@web.de> - 2014-11-10 20:19 +0100
Re: "Natural" use of cmp= in sort Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-10 12:43 -0700
Re: "Natural" use of cmp= in sort Paddy <paddy3118@gmail.com> - 2014-11-10 18:03 -0800
Re: "Natural" use of cmp= in sort Paddy <paddy3118@gmail.com> - 2014-11-10 19:09 -0800
Re: "Natural" use of cmp= in sort Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-10 23:36 -0700
Re: "Natural" use of cmp= in sort Paddy <paddy3118@gmail.com> - 2014-11-10 23:44 -0800
Re: "Natural" use of cmp= in sort Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-11 01:35 -0700
Re: "Natural" use of cmp= in sort Paddy <paddy3118@gmail.com> - 2014-11-11 01:21 -0800
Re: "Natural" use of cmp= in sort Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-11 10:59 -0700
Re: "Natural" use of cmp= in sort Paddy <paddy3118@gmail.com> - 2014-11-12 00:09 -0800
csiph-web