[Python-Dev] Python 2.4 | 7.3 The for statement

Juan Carlos Rodrigo Garcia jrodrigog at gmail.com
Sun Mar 20 03:25:24 CET 2005

Hi My name is Juan Carlos Rodrigo, and I love Python. 
It is the most impressive and usefull language that
I have ever seen. 

I am studing, at http://www.uoc.edu, an Information 
Technology Postgraduate. And I have programmed some 
REXX applications in my past Jobs (So I love python, 
no more ENDS).

This is my Graduate final project http://ip.xpyro.com 
made in mod_python. I love mod_python too.

Please don't crash my AMD making queries. :|


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" expression ] ":" 
  suite ["else" ":" suite]

  ** If the expression evaluates to False before 
     entering the for, jump else.
  ** If the expression is evaluated to False after 
     the first iteration, break.
So ¿What we can do with this new for?, 
and ¿It is going to avoid line exceed?:
"My second remark is that our intellectual powers are rather
geared to master static relations and that our powers to
visualize processes evolving in time are relatively poorly
developed." [1]
It is easier if we see it beforehand:
leave = False
alist = [1,2,3,3,4,5,6,7,8,9]
for item in alist and not leave:
 if item is 1: leave = True
Avoiding code exceed:
a = 1
b = 2
c = 3
alist = [1,2,3,4,5,6,7,8,9]
for item in alist and a < 2 and b < 3 and c < 4:
 if item == 3: a += 1
 if item == 2: b += 1
 if item == 1: c += 1
print "%d %d %d" % (a,b,c)
# three lines off (25% less on breaks)

Other features and the else:
alist = [1,2,3]
enter = False
if list[0] == 4:
 enter = True
for item in alist and enter:
 print item
 print "No account"
The real problem:
"The exercise to translate an arbitrary flow diagram more or
less mechanically into a jump-less one, however, is not to be
recommended." [1]
Ok, it's not recommended, at large, but Python should make it possible,
and then the people will choose.
[1] Go To Statement Considered Harmful
Edsger W. Dijkstra
PD: Your work is impressive, thanks.

Juan Carlos Rodrigo Garcia.
jrodrigog at gmail.com

More information about the Python-Dev mailing list