[Python-il] Python coding question

Ahik Man ahik.man at gmail.com
Thu Jul 1 14:48:07 IDT 2010


What do you think about this code:

for n in range(2, 10):...     for x in range(2, n):...         if n %
x == 0:...             print n, 'equals', x, '*', n/x...
break...     else:...         # loop fell through without finding a
factor...         print n, 'is a prime number'


I don't like this 'for - else' trick. IMHO it's confusing and not readable.

BTW, This code is taken from the python tutorial:
http://docs.python.org/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops


Ahik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://hamakor.org.il/pipermail/python-il/attachments/20100701/a64633fc/attachment.htm 


More information about the Python-il mailing list