Minimum and Maximum of a list containing floating point numbers
Ben Finney
ben+python at benfinney.id.au
Mon Sep 6 22:40:57 EDT 2010
Steven D'Aprano <steve-REMOVE-THIS at cybersource.com.au> writes:
> On Tue, 07 Sep 2010 11:00:45 +1000, Ben Finney wrote:
>
> > If you're going to use the list of float objects, you can convert them
> > all with a list comprehension.
> [...]
> > >>> numbers_as_float = [float(x) for x in numbers_as_str]
>
> That's awfully verbose. A map is simpler:
>
> numbers_as_float = map(float, numbers_as_str)
I'll pay “verbose”, but not “awfully”. There is little difference in
verbosity between your example and mine. Further, I don't see my example
as excessive, which I assume your “awfully” entails.
--
\ “I call him Governor Bush because that's the only political |
`\ office he's ever held legally.” —George Carlin, 2008 |
_o__) |
Ben Finney
More information about the Python-list
mailing list