Fastest way to max() list

David Di Biase dave.dibiase at gmail.com
Thu Sep 25 23:57:06 EDT 2008


I have a list with about 1000-1500 sub-lists which look like so:
list[-0.28817955213290786, 3.6693631467403929, 'H', 31.31225233035784]]

The first and second values are Angstrom units specifying the location of a
particle. What I'd like to do is determine the distance between the smallest
and largest value in the arrays first position 0. I tried reading the manual
for this but I don't see how it applies key or any of those other commands
to the function. I could easily write a sort to do this and capture the
first and last spots, but why do that when I can use max and min (if I can
actually do that...).

So you wonderful Python gods, lay some knowledge on me. please? lol...

while I'm at it, is there a way to modify an entire list without having to
produce a whole new one? For example now say I want to modify list[0] and
multiply it by some value. From what I understand previous version of Python
allowed lists to be multiplied like matrices...now apparently it just
replicates the list. :-/ shucks...

The first question would be useful to know, but the second question I do
quite a bit of and the "best practice" would be really great to know!

Thanks in advanced!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080925/68037586/attachment.html>


More information about the Python-list mailing list