define loop statement?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Feb 16 20:18:51 EST 2006


David Isaac:
> I would like to be able to define a loop statement
> (nevermind why) so that I can write something like
>
> loop 10:
>     do_something
>
> instead of
>
> for i in range(10):
>     do_something
>
> Possible?  If so, how?

It seems that you are looking for macros; maybe Logix "language"
(www.livelogix.net/logix) or Boo (boo.codehaus.org) can solve your
problem.
Otherwise you can do it with very different languages like Lisp or
Scheme (with a different syntax) and maybe Dylan too.

If you tell us your purpose, maybe we can suggest you a
better/different solution.

Bye,
bearophile




More information about the Python-list mailing list