a good explanation

s99999999s2003 at yahoo.com s99999999s2003 at yahoo.com
Thu May 25 07:27:59 EDT 2006


hi
my friend has written a loop like this
cnt = 0
files = [a,b,c,d]
while cnt < len(files) :
   do_something(files[cnt])

i told him using
for fi in files:
   do_something(fi)

is better, because the while loop method makes another call to
len..which is slower..
am i partly right? or is there a better explanation for using the for
method.?
thanks




More information about the Python-list mailing list