No, loop-and-a-half! (Re: REPEAT... UNTIL ?)

Rich Harkins rich at worldsinfinite.com
Fri Jul 12 09:52:06 EDT 2002


> I like that kind of syntax. I'd like to propose an alternative
> keyword:
>
>   while cond1:
>     dofoo()
>   andwhile cond2:
>     dobar()
>

So does this eqate to the following in current python?

while cond1:
	dofoo()
	if cond2:
		dobar()

or?

while cond1:
	dofoo()
	if cond2:
		dobar()
	else:
		break

> with an analogous structure:
>
>   if cond1:
>     dofoo()
>   andif cond2:
>     dobar()
>   else:
>     doqux()
>

and this?

if cond1:
	dofoo()
	if cond2:
		dobar()
else:
	doqux()

or?

if cond1:
	dofoo()
	if cond2:
		dobar()
	else:
		doqux()
else:
	doqux()

> where foo is done if cond1, bar is done if (cond1 and cond2) and qux
> is done if not (cond1 and cond2). For consistency with elif it could
> be called anif instead?

What if I get more complicated:

if cond1:
	true1()
andif cond2:
	true2()
elif cond3:
	true3()
andif cond4:
	true4()
else:
	false()

How does this translate to current Python?  (I'm gettting a headache now)

I think I like Python's explicit nature better than these cases (as well as 
the all of the messages in this thread).  I don't have to guess how Python 
will process my instructions nor do I have to think very hard about what a 
program will do when reading it.

Rich






More information about the Python-list mailing list