> 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
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..
>
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
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
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
[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
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
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