Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Bengt Richter
On 25 Mar 2005 15:41:25 -0800, "brainsucker" <[EMAIL PROTECTED]> wrote: >Franciso, some more code. > >Breaking with two conditions, and fun with exceptions: > >moflo = 1 >try: > for item1 in range(10): >if (item1 * moflo) == 3: raise StopIteration >for item2 in range(10): > if (item2

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread brainsucker
Franciso, some more code. Breaking with two conditions, and fun with exceptions: moflo = 1 try: for item1 in range(10): if (item1 * moflo) == 3: raise StopIteration for item2 in range(10): if (item2 * moflo) == 2: raise StopIteration print "Let's see" except StopIteration:

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread brainsucker
As you know is not functional... It represents something that happens everyday on Python programming. We can reduce the other examples of code to: prinf foo Too. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread brainsucker
Well facundo, I knew that you were going for the return inside the loop. The exception is cool, but not for newcomers. My proposend code is simpler clearer and more compact, I keep watching your code, and don't know Funcs for breaking loops, exceptions for breaking loops. :o -- http://mail.p

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Ron_Adam
>-- Your code >foo = 0 >for item1 in range(10): > for item2 in range(10): >foo = item1 + item2 >if foo == 2: > print "Let's see" > break # let's go > if (item1 + item2) == 2: >break # one more time >print foo The outer loop never reaches 1, so we can get rid of it along wi

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Facundo Batista
On 24 Mar 2005 19:49:38 -0800, brainsucker <[EMAIL PROTECTED]> wrote: > foo = 0 > for item1 in range(10) until foo == 2: > for item2 in range(10) until foo == 2: > foo = item1 + item2 > if foo == 2: print "Let's see" > print foo In this case, I'll use the following: try: for item1

Re: Python 2.4 | 7.3 The for statement

2005-03-24 Thread brainsucker
>And that could be modified even further, using current >(unextended) Python... Nice code Wulfraed (or Dennis), back to the basics: -- Your code foo = 0 for item1 in range(10): for item2 in range(10): foo = item1 + item2 if foo == 2: print "Let's see" break # let's go if (

Re: Python 2.4 | 7.3 The for statement

2005-03-22 Thread brainsucker
>Still, this can be acomplished with the break statement, in a more >clear way, with less variables (which implies less work for the gc and >everybody). Glad to read from you Francisco. :) Keep up that hard work, thanks. I have been talking with those Python programmers (And Role players), :) and

Re: Python 2.4 | 7.3 The for statement

2005-03-22 Thread Facundo Batista
On 22 Mar 2005 06:32:38 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > The for definition could be like this: > > for_stmt ::= "for" target_list "in" expression_list > [ "until" expression ] ":" > suite ["else" ":" suite] > > or some other word that clarifies the work of t

Re: Python 2.4 | 7.3 The for statement

2005-03-22 Thread he . dicho . que . no . quiero . spam
brainsucker wrote: > Python 2.4 | 7.3 The for statement: > --- > > for_stmt ::= "for" target_list "in" expression_list ":" > suite ["else" ":" suite] > > > New for statement: > -- > > for_stmt ::= "for" target_list "in" expression_list > [ "and"