Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41143
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!137.226.231.214.MISMATCH!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jeanpierreda@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '[0]': 0.07; 'appropriate.': 0.09; 'valueerror': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; 'none).': 0.16; 'subject:3.3': 0.16; 'input': 0.18; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '[1]': 0.27; 'cc:addr:gmail.com': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:list': 0.28; 'received:google.com': 0.34; 'minimum': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'said:': 0.65; 'subject:Min': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=WqyQbcthJwJ41e90Ljz9tpvOOpcc8pqDzaBcHzBRaHc=; b=id/crDhTuMCYk1R2N7GdnBZgONABxws3quM0iEKeNESb3BLPxglO4DoUMfqNU4QyTc ndl6cDJ9JwfHvWQ/LfCzIeQuwmJi634nGfxgmNAmIkZG+0K7G867/UVPcnkvh7fzTQvJ 6J+j7IOClB3P+uwRqXEhtPiofvr0tTU9zoJ/OFpq1Ox2HdosuMZjJ7MuzVWL2bo1B4D0 +ssiJ+D7amaeho7OoCBufAxV6vwIN9J1hag9N40wx2C9qL5PHZ2/9FBhqUZnRFavou5S gPIzBcyEHKh/5AtUSe//Shhs0p4ugxAvepeXFjXNRBBG2Lkm8ctsaJSTaknOVSVa7aRT zwXQ== |
| X-Received | by 10.52.68.116 with SMTP id v20mr5941660vdt.126.1363110620859; Tue, 12 Mar 2013 10:50:20 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <1604147031.4067302.1363110301286.JavaMail.root@sequans.com> |
| References | <abcd1234abc123ab12a0000000027000020000001052@gmail.com> <1604147031.4067302.1363110301286.JavaMail.root@sequans.com> |
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | Tue, 12 Mar 2013 13:49:40 -0400 |
| Subject | Re: Finding the Min for positive and negative in python 3.3 list |
| To | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3244.1363110630.2939.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1363110630 news.xs4all.nl 6893 [2001:888:2000:d::a6]:41974 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:41143 |
Show key headers only | View raw
> min(a)
This does not return a negative minimum on input [1] (because there is none).
> and
>
> min([e for e in a if e >=0]
This does not return a positive minimum on input [0] (because there is none).
I would have said:
pos_min = min(e for e in a if e > 0)
neg_min = min(e for e in a if e < 0)
And then deal with the ValueError when there is no such minimum, as appropriate.
-- Devin
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Finding the Min for positive and negative in python 3.3 list Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-03-12 13:49 -0400
csiph-web