define loop statement?
Georg Brandl
g.brandl-nospam at gmx.net
Thu Feb 16 16:08:38 EST 2006
David Isaac wrote:
> 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's not possible to create a new statement, with suite
and indentation rules without hacking the interpreter or
resorting to alternative bytecode compilers such as "pyc".
Creating a _function_ named "loop" is easy as Jonathan's
answer shows.
Georg
More information about the Python-list
mailing list