Finding the Min for positive and negative in python 3.3 list
jeanpierreda at gmail.com
Tue Mar 12 18:49:40 CET 2013
This does not return a negative minimum on input  (because there is none).
> min([e for e in a if e >=0]
This does not return a positive minimum on input  (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.
More information about the Python-list