[Python-ideas] Simpler syntax for basic iterations

Ben Finney ben+python at benfinney.id.au
Mon Oct 12 00:03:27 CEST 2015


Luciano Ramalho <luciano at ramalho.org>
writes:

> I've felt the same need Andre described, and so far I have not seen a
> convincing argument against his proposal to accept this syntax:
>
> for n:  # repeat block n times
>      fd(100)
>      lt(360/n)
>
> Where n is any expression that evaluates to an integer.

Huh? If ‘n’ is an expression that evaluates to one integer, then why are
you also dividing by that one integer ‘n’ every time through?


I don't claim it will convince you, but I find compelling the fact that
this::

    for n in range(FOO):
         fd(100)
         lt(360/n)

already works fine and is quite clear.

-- 
 \         “Science is a way of trying not to fool yourself. The first |
  `\     principle is that you must not fool yourself, and you are the |
_o__)               easiest person to fool.” —Richard P. Feynman, 1964 |
Ben Finney



More information about the Python-ideas mailing list