Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PEP 315: Enhanced While Loop

Thread Tools

PEP 315: Enhanced While Loop

Daniel Cotton
Posts: n/a
During some random surfing I became interested in the below piece of code:

> while <condition1>:
> <code1>
> and while <condition2>:
> <code2>
> and while <condition3>:
> <code3>
> else: <other code>

It strikes me that the 'and while' syntax has some power that you may
not have considered. Consider that if an 'and while' were to be
executed under some condition:

if <conditionX>:
and while <conditionY>:

you would then have a live loop condition that applied to subsequent
iterations only if conditionX was met. Under this circumstance I
wondered if you might also want a method of cancelling while
conditions? For example:

cancel while <conditionY>:

where the 'cancel while' command removes conditionY from the list of
conditions that the loop will terminate on. You could then also use
this syntax to cancel the initial while condition.

I also wondered if 'or while' might be better, so that you could add
different types of prefix to a while condition, i.e. 'and while'.

I'm a python novice so this could well be something you want to ignore
but I wasn't doing anything anyway. Let me know what you think.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
jdk 1.5 enhanced for loop, Iterable and arrays Remi Bastide Java 5 03-29-2010 11:28 AM
Whats the difference between while loop in Windows message loop and while(1) Uday Bidkar C++ 4 12-12-2006 12:30 PM
while loop in a while loop Steven Java 5 03-30-2005 09:19 PM
PEP-0315--Enhanced While Loop: An idea for an alternative syntax Andrew Koenig Python 46 02-24-2004 07:14 PM