Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41143 > unrolled thread
| Started by | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| First post | 2013-03-12 13:49 -0400 |
| Last post | 2013-03-12 13:49 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Finding the Min for positive and negative in python 3.3 list Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-03-12 13:49 -0400
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| Date | 2013-03-12 13:49 -0400 |
| Subject | Re: Finding the Min for positive and negative in python 3.3 list |
| Message-ID | <mailman.3244.1363110630.2939.python-list@python.org> |
> 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 top | Article view | comp.lang.python
csiph-web