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
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:
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
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
>-- 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
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
>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 (
>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
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
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"
10 matches
Mail list logo