Re: a good explanation

2006-05-26 Thread Diez B. Roggisch
> Something that is being missed is the idea of changing conditions. A > for loop assumes known boundaries. > > def condition_test(): > # check socket status > # return true if socket good, false otherwise > > while condition_test(): ># do stuff > > allows the loopiing code to react to c

Re: a good explanation

2006-05-26 Thread [EMAIL PROTECTED]
Nick Craig-Wood wrote: > mik3 <[EMAIL PROTECTED]> wrote: > > So he has written his first program in python and i have roughly toook > > a glance at it and saw what he did.. i pointed out his "mistakes" but > > couldn't convince him otherwise. Anyway , i am going to show him your > > replies.. >

Re: a good explanation

2006-05-25 Thread Nick Craig-Wood
mik3 <[EMAIL PROTECTED]> wrote: > So he has written his first program in python and i have roughly toook > a glance at it and saw what he did.. i pointed out his "mistakes" but > couldn't convince him otherwise. Anyway , i am going to show him your > replies.. You might want to show him this t

Re: a good explanation

2006-05-25 Thread mik3
wow!...thanks for both replies..and yes you are right, he comes from a world of C and java...i have successfully "brainwashed" him to try out coding in python...haha. So he has written his first program in python and i have roughly toook a glance at it and saw what he did.. i pointed out his "mista

Re: a good explanation

2006-05-25 Thread John Machin
On 25/05/2006 9:27 PM, [EMAIL PROTECTED] wrote: > 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 ano

Re: a good explanation

2006-05-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > 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..w

Re: a good explanation

2006-05-25 Thread Bas
I guess that your version is faster, although the difference would be negligible in this small example. The for loop is probably optimized for speed under the hood (it is written in C), while the 'while' loop is performed in python, which is much slower. Much more important than the speed differen

a good explanation

2006-05-25 Thread s99999999s2003
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 bet