Maybe a stupid idea

John Roth newsgroups at
Wed Dec 31 20:05:14 CET 2003

"sebb" <sebb at> wrote in message
news:56f42e53.0312310949.39826ffd at
> I'm kind of newbie to programming, but I thought of something and I
> want some opinions on that.
> It's about a new instruction block to do some cycles.
> I thought about that because it's not very easy to program a cycle.
> Here is a simple example :
> b=0
> while b < 50:
>     b+=1
>     print "*" * b
> while b > 0:
>     b-= 1
>     print "*" * b
> It takes two while blocks to do a cycle.

I take it you want to go up a sequence and then back down.

A somewhat simpler (at least, fewer lines) implementation
of your example:

for b in range(1, 50):
    print "*" * b
for b in range (49, 0, -1):
    print "*" * b

This eliminates the need to control the variable.

> I know that cycles is not a structure of any programming language, but
> I want some opinions the know if my idea is stupid or not.

It's the type of thing that, while useful, isn't of enough general
utility to put into a language, especially as it's easy enough to
create it whenever you need it.

Python development has a definite bias in favor of not adding
things to the language unless they would be widely useful.

John Roth

More information about the Python-list mailing list