Proposal: min(None, x) and max(None, x) return x
Chad Netzer
cnetzer at mail.arc.nasa.gov
Fri Nov 22 18:42:21 EST 2002
On Friday 22 November 2002 14:57, Alex Martelli wrote:
> perhaps a slightly better expression of the same idea might be...
>
> _xMax = []
> for -whatever-:
> -big calculation leading to a value of x-
> _xMax = [max([x]+_xMax)]
> xMax = _xMax[0]
Thanks. I knew if I posted this, someone would follow up with an improved
way of doing it (I didn't like the .append() myself, and overlooked list
concatenation). Note that I put the 'xMax' assignment in the loop (assuming
that's what the original poster required); otherwise you can avoid typing
'_xMax':
xMax = []
for -whatever-:
-big calculation leading to a value of x-
xMax = [max([x]+xMax)]
xMax = xMax[0]
--
Bay Area Python Interest Group - http://www.baypiggies.net/
Chad Netzer
cnetzer at mail.arc.nasa.gov
More information about the Python-list
mailing list