Perl to Python

Loops

While

while a>1:
  print a
while true:
  pass  # does nothing

{i} You cannot say while row=mysql.fetchone(): in Python. Use the iter command like this:

for row in iter(cursor.fetchone, None):
  do_something...

If

if a>1:
  ...
elif a<1:
  ...
else:
  ...

For

for element in list:
  print element
for i in range(10):
  print i

WorkaroundOrg: PerlToPython/ControlStructures (last edited 2005-08-29 17:52:58 by ChristophHaas)